Text
Displays text.
component Text
Example
import { Text } from ui
export var main = Text("Hello, world!")
Constructor
constructor(
_ text: String,
color: Color? = nil,
size: Int? = nil,
font_family: FontFamilyName? = nil,
italic: Bool = false,
font_weight: Int = font_weights.normal,
letter_spacing: Float? = nil,
line_height: Float? = nil,
line_limit: Int? = nil,
multiline_alignment: HorizontalAlignment? = nil
)
_ text: StringThe text to display
color: Color? = nil // nil == inherited from environmentThe text's color.
See Color
size: Int? = nil // nil == inherited from environmentThe text's size in pixels.
font_family: FontFamilyName? = nil // nil == inherited from environmentThe font family.
See FontFamilyName
See load_fontitalic: Bool = falseEnables the italic style.
font_weight: Int = font_weights.normalFont weight.
See font_weights
letter_spacing: Float? = nil // nil == inherited from environment(8.11)Additional spacing between characters in pixels. Can be negative to tighten character spacing.
See LetterSpacing
line_height: Float? = nil // nil == inherited from environment(8.11)A multiplier applied to the line height. For example,
1.5results in 150% of the font's natural line height.See LineHeight
line_limit: Int? = nil // nil == inherited from environmentThe maximum number of lines the text can be broken onto.
multiline_alignment: HorizontalAlignment? = nil // nil == inherited from environmentThe alignment of the individual lines when text breaks.
Layout Behavior
Tries to occupy the exact space needed to display the text. If the horizontal space isn't enough it will try to wrap the lines vertical until everything is displayed or no more space is left. As a last resort, the text is elided to fit into the available space.
Text will never use more space than needed.