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

wf

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

wf

Stack { Text("Primary").primary Text("Secondary").secondary Text("Saved").success Text("Needs attention").warning Text("Failed").danger Text("Did you know?").info }

Alignment

wf

Stack { Text("Left").left Text("Centred").center Text("Right").right }

As a heading or a subtitle, without being one

wf

Stack { Text("Release notes").heading Text("Everything in 7.0.1").subtitle }

Live: a splice that reads state

wf

state count = 3 Text("{count} items in your cart").bold.underline

Props

Props of Text
PropTypeUnsetMeaning

content

String or Number or Bool (positional)

none

The text, a <p>: a string, a number or a boolean; a splice in it follows state

tone:

one of its cases

none: the text's colour

Its colour, a tone of the theme. Written as a flag, .primary, or by name, tone: .primary.

  • .primary: The theme's primary colour
  • .secondary: The theme's secondary colour
  • .success: Green: done, healthy
  • .danger: Red: destructive, failed
  • .warning: Amber: needs attention
  • .info: Blue: a neutral notice

size:

one of its cases

md

Its font size. Written as a flag, .sm, or by name, size: .sm.

  • .sm: font-size-sm, 0.875rem
  • .md (the default): The size it inherits (the default)
  • .lg: font-size-lg, about 1.125–1.25rem

align:

one of its cases

none: the start, as inherited

Where its lines sit. Written as a flag, .left, or by name, align: .left.

  • .left: To the start of the line (text-align: start; the right in a right-to-left page)
  • .center: Centred
  • .right: To the end of the line (text-align: end; the left in a right-to-left page)

transform:

one of its cases

none

The case its letters are drawn in; the text itself is unchanged. Written as a flag, .uppercase, or by name, transform: .uppercase.

  • .uppercase: ALL CAPS
  • .lowercase: all lower case

kind:

one of its cases

none

A typographic role, still a <p>. Written as a flag, .heading, or by name, kind: .heading.

  • .heading: Bold, at font-size-lg: a label that reads as a heading without being one in the outline
  • .subtitle: Small (font-size-sm) and muted

bold:

Bool

false

Bold (font-weight-bold). Written as a flag, .bold, or bold: true.

italic:

Bool

false

Italic. Written as a flag, .italic, or italic: true.

underline:

Bool

false

Underlined. Written as a flag, .underline, or underline: true.

muted:

Bool

false

In color-text-muted, for secondary text. Written as a flag, .muted, or muted: true.

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.