Skip to main content

Text

The Text widget is the most basic widget for showing a string on screen.
Use it for every piece of text — titles, descriptions, labels, and more.

info

Example file: 07_Work_with_Widgets/text_objet.lfp

Definition and role

The Text widget draws the string you specify on screen. By default a single style — color, size, alignment, and so on — applies to the whole string, but setStyledText in a script lets you color individual parts of the text differently. To write rich text directly in the editor, use the RichText widget.

  • Category: Contents
  • Default text: Hello World

Features

FeatureDescription
Text displayShows the string you enter. Supports multiline input.
Data bindingBind the text content to data so the value updates automatically.
Alignment and wrappingSet paragraph alignment, automatic wrapping, the maximum number of lines, and overflow handling.
Script controlChange the text content, color, and size in real time from a script.

How to use

  1. Open the Contents category in the left widget palette.
  2. Drag and drop the Text item onto the canvas.
  3. Select the widget you placed, then edit its text value in the Properties panel on the right.
  4. If you need to, adjust the alignment (textAlign), maximum number of lines (maxLines), and overflow handling (overflow).

Properties

note

The table below follows the order the options appear in the Studio Properties panel, top to bottom. Expand the style row for sub-options such as text color, size, weight, and font. (Styles modifiers like SizedBox and Padding live in the separate Styles panel, so they differ from the properties here.)

OptionDescriptionDefaultValues / type
textString to display (multiple lines and data binding supported)Empty stringString
styleText style — color, size, weight, font, and more (expand for sub-options)Not set (theme default)TextStyle (group)
textAlignParagraph alignmentstartleft, right, center, justify, start, end
textDirectionDirection the text runsNot set (inherited)ltr, rtl
softWrapWraps automatically when the text exceeds the widthOn (true)True / false
overflowHow overflowing text is handledclipclip, fade, ellipsis, visible
textScaleFactorText size multiplier1.0Number
maxLinesMaximum number of lines to display (unlimited unless you add the property; the excess follows overflow)0 (when the property is added)Integer (1 or higher)
localeLocale — language and regionNot setLocale
strutStyleLine-height baseline (strut)Not setStrutStyle
textWidthBasisBasis for measuring the text widthparentparent, longestLine
textHeightBehaviorHeight handling for the first and last linesNot setTextHeightBehavior

Notes and tips

note

maxLines is the maximum number of lines to display. Adding the property sets it to 0, so change it to the maximum you actually want (1 or higher). Without the property, there is no limit on the number of lines.

tip

To end long text with ... instead of cutting it off, set maxLines and set overflow to ellipsis.

Learn more

tip

For the full set of Widget Control members (Property, Method, Event) that drive this widget from a script, see Text Widget Control.