Skip to content

Text

A view that displays one or more lines of read-only text.

<Text ... />

Overview

Accepts a plain string or a table whose first element is the string. Use size and weight for hierarchy; prefer system typography over hard-coded custom fonts. Long text wraps under the parent width proposal unless lineLimit truncates it.

Topics

Properties

Name Type Required Description
[1] string required Label content.
size number optional System font size in points.
weight string optional System font weight (e.g. "bold", "semibold").
color string optional Semantic system color name.
alignment string optional One of "leading", "center", "trailing".
lineLimit number optional Maximum lines; 0 means unlimited.
underlinesOnHover boolean optional Underlines the text while the pointer is over it, for a label that acts on click (SwiftUI .underline(isHovered)).
reservesSpace boolean optional Always as tall as lineLimit lines, so shorter text never moves siblings (SwiftUI .lineLimit(n, reservesSpace: true)).
truncation string optional One of "head", "middle", "tail".
wrapping string optional "word" (default) or "character".
monospacedDigit boolean optional Uses fixed-width digits so changing numbers do not shift (SwiftUI .monospacedDigit()); requires size.
minimumScaleFactor number optional Smallest fraction of size the text shrinks to when offered less width (SwiftUI .minimumScaleFactor).

Example

<Label>Hello</Label>
<Label size="16" weight="bold">Hello</Label>

Platform notes

  • AppKit NSTextField (non-editable, bezel-less). UIKit UILabel.

See Also


Source: lua/embedded/AppKit.lua:969 (AppKit.Text)