Reference
Text
A paragraph of text. {…} in the string reads state and stays live.
Text(_ content: String or Number or Bool, tone: Enum, size: Enum, align: Enum, …)
Before 5.0
tone
size
align
transform
kind
Billing
Your plan renews on 1 December.
Payment failed: the card was declined.
Updated 3 minutes ago
Example
Stack(gap: .xs) {
Text("Billing").uppercase.sm.muted
Text("Your plan renews on 1 December.").lg
Text("Payment failed: the card was declined.").danger.bold
Text("Updated 3 minutes ago").muted.sm.italic
}
Tones
Stack {
Text("Primary").primary
Text("Secondary").secondary
Text("Saved").success
Text("Needs attention").warning
Text("Failed").danger
Text("Did you know?").info
}
Alignment
Stack {
Text("Left").left
Text("Centred").center
Text("Right").right
}
As a heading or a subtitle, without being one
Stack {
Text("Release notes").heading
Text("Everything in 7.0.1").subtitle
}
Live: a splice that reads state
state count = 3
Text("{count} items in your cart").bold.underline
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
content | String or Number or Bool (positional) | none | The text, a |
tone: | one of its cases | none: the text's colour | Its colour, a tone of the theme. Written as a flag,
|
size: | one of its cases |
| Its font size. Written as a flag,
|
align: | one of its cases | none: the start, as inherited | Where its lines sit. Written as a flag,
|
transform: | one of its cases | none | The case its letters are drawn in; the text itself is unchanged. Written as a flag,
|
kind: | one of its cases | none | A typographic role, still a
|
bold: | Bool | false | Bold ( |
italic: | Bool | false | Italic. Written as a flag, |
underline: | Bool | false | Underlined. Written as a flag, |
muted: | Bool | false | In |
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
.primary
.secondary
.success
.danger
.warning
.info
.sm
.md
.lg
.left
.center
.right
.uppercase
.lowercase
.heading
.subtitle
.bold
.italic
.underline
.muted
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
It takes no slots.
Renders with the class wf-text, stable across releases, so a stylesheet may target it.