Skip to main content

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: String

The text to display

color: Color? = nil // nil == inherited from environment

The text's color.

See Color

size: Int? = nil // nil == inherited from environment

The text's size in pixels.

font_family: FontFamilyName? = nil // nil == inherited from environment

The font family.

See FontFamilyName
See load_font

italic: Bool = false

Enables the italic style.

font_weight: Int = font_weights.normal

Font 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.5 results in 150% of the font's natural line height.

See LineHeight

line_limit: Int? = nil // nil == inherited from environment

The maximum number of lines the text can be broken onto.

multiline_alignment: HorizontalAlignment? = nil // nil == inherited from environment

The alignment of the individual lines when text breaks.

See HorizontalAlignment

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.