Text
Display text primitive: consumes global typography tokens, with font-size levels, weight, tone and alignment.
Contract:
lh-ui-core/specs/text.json· Golden cases:lh-ui-core/cases/text.json(5, translated to XCTest, runnable on macOS host)
Font-size levels
level maps to the typography.fontSize.<level> token; default base.
extraLarge
large
medium
base
small
extraSmall
HTML simulator preview (iOS / SwiftUI appearance), not a real device render
LhText("Title text", level: .large)Weight
weight maps to the typography.fontWeight.<weight> token (primary 400 / bold 600).
primary
bold
HTML simulator preview (iOS / SwiftUI appearance), not a real device render
Tone
tone maps to the color.text.<tone> token; selected takes color.selected.
primary
regular
secondary
placeholder
disabled
selected
HTML simulator preview (iOS / SwiftUI appearance), not a real device render
Alignment and line height
lhAlign aligns within the line box; line height always takes typography.lineHeight.primary (font size × 1.8).
center
end
HTML simulator preview (iOS / SwiftUI appearance), not a real device render
LhText("Centered", lhAlign: .center)API
| Prop | Description | Type | Default |
|---|---|---|---|
content | text content (first initializer argument; the spec default slot) | String | "" |
level | Font-size levels | LhTextLevel | .base |
weight | Weight | LhTextWeight | .primary |
tone | Tone | LhTextTone | .primary |
lhAlign | Alignment and line height | LhTextAlign | .start |
LhTextLevel
| Prop | fontSize token |
|---|---|
.extraLarge | typography.fontSize.extraLarge (20pt) |
.large | typography.fontSize.large (18pt) |
.medium | typography.fontSize.medium (16pt) |
.base | typography.fontSize.base (14pt, default) |
.small | typography.fontSize.small (13pt) |
.extraSmall | typography.fontSize.extraSmall (12pt) |
LhTextTone
| Prop | text color token |
|---|---|
.primary | color.text.primary |
.regular | color.text.regular |
.secondary | color.text.secondary |
.placeholder | color.text.placeholder |
.disabled | color.text.disabled |
.selected | color.selected |
Token reference
| Token | Usage |
|---|---|
typography.fontSize.<level> | six size levels |
typography.fontWeight.{primary,bold} | two weights |
typography.lineHeight.primary | line height (font size × 1.8) |
color.text.<tone> / color.selected | text tones |
Golden case reference
| case id | Assertion | Local test |
|---|---|---|
default-level-uses-base-tokens | default level consumes the base typography tokens | LhTextTests.testDefaultLevelUsesBaseTokens |
large-level-uses-large-token | large level consumes the large size token | LhTextTests.testLargeLevelUsesLargeToken |
bold-weight-uses-bold-token | bold consumes the bold weight token | LhTextTests.testBoldWeightUsesBoldToken |
secondary-tone-uses-text-secondary | secondary tone takes the secondary text color token | LhTextTests.testSecondaryToneUsesTextSecondary |
render-emits-single-text-command | render emits a single TEXT command | LhTextTests.testAllLevelsUseTheirTokens |
swift test --filter LhTextTests
