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.
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
| Feature | Description |
|---|---|
| Text display | Shows the string you enter. Supports multiline input. |
| Data binding | Bind the text content to data so the value updates automatically. |
| Alignment and wrapping | Set paragraph alignment, automatic wrapping, the maximum number of lines, and overflow handling. |
| Script control | Change the text content, color, and size in real time from a script. |
How to use
- Open the Contents category in the left widget palette.
- Drag and drop the Text item onto the canvas.
- Select the widget you placed, then edit its
textvalue in the Properties panel on the right. - If you need to, adjust the alignment (
textAlign), maximum number of lines (maxLines), and overflow handling (overflow).
Properties
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.)
| Option | Description | Default | Values / type |
|---|---|---|---|
text | String to display (multiple lines and data binding supported) | Empty string | String |
style | Text style — color, size, weight, font, and more (expand for sub-options) | Not set (theme default) | TextStyle (group) |
textAlign | Paragraph alignment | start | left, right, center, justify, start, end |
textDirection | Direction the text runs | Not set (inherited) | ltr, rtl |
softWrap | Wraps automatically when the text exceeds the width | On (true) | True / false |
overflow | How overflowing text is handled | clip | clip, fade, ellipsis, visible |
textScaleFactor | Text size multiplier | 1.0 | Number |
maxLines | Maximum 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) |
locale | Locale — language and region | Not set | Locale |
strutStyle | Line-height baseline (strut) | Not set | StrutStyle |
textWidthBasis | Basis for measuring the text width | parent | parent, longestLine |
textHeightBehavior | Height handling for the first and last lines | Not set | TextHeightBehavior |
Notes and tips
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.
To end long text with ... instead of cutting it off, set maxLines and set overflow to ellipsis.
Learn more
For the full set of Widget Control members (Property, Method, Event) that drive this widget from a script, see Text Widget Control.