Skip to content

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.

9:41Text

extraLarge

large

medium

base

small

extraSmall

HTML simulator preview (iOS / SwiftUI appearance), not a real device render

swift
LhText("Title text", level: .large)

Weight ​

weight maps to the typography.fontWeight.<weight> token (primary 400 / bold 600).

9:41Text

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.

9:41Text

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).

9:41Text

center

end

HTML simulator preview (iOS / SwiftUI appearance), not a real device render

swift
LhText("Centered", lhAlign: .center)

API ​

PropDescriptionTypeDefault
contenttext content (first initializer argument; the spec default slot)String""
levelFont-size levelsLhTextLevel.base
weightWeightLhTextWeight.primary
toneToneLhTextTone.primary
lhAlignAlignment and line heightLhTextAlign.start

LhTextLevel ​

PropfontSize token
.extraLargetypography.fontSize.extraLarge (20pt)
.largetypography.fontSize.large (18pt)
.mediumtypography.fontSize.medium (16pt)
.basetypography.fontSize.base (14pt, default)
.smalltypography.fontSize.small (13pt)
.extraSmalltypography.fontSize.extraSmall (12pt)

LhTextTone ​

Proptext color token
.primarycolor.text.primary
.regularcolor.text.regular
.secondarycolor.text.secondary
.placeholdercolor.text.placeholder
.disabledcolor.text.disabled
.selectedcolor.selected

Token reference ​

TokenUsage
typography.fontSize.<level>six size levels
typography.fontWeight.{primary,bold}two weights
typography.lineHeight.primaryline height (font size × 1.8)
color.text.<tone> / color.selectedtext tones

Golden case reference ​

case idAssertionLocal test
default-level-uses-base-tokensdefault level consumes the base typography tokensLhTextTests.testDefaultLevelUsesBaseTokens
large-level-uses-large-tokenlarge level consumes the large size tokenLhTextTests.testLargeLevelUsesLargeToken
bold-weight-uses-bold-tokenbold consumes the bold weight tokenLhTextTests.testBoldWeightUsesBoldToken
secondary-tone-uses-text-secondarysecondary tone takes the secondary text color tokenLhTextTests.testSecondaryToneUsesTextSecondary
render-emits-single-text-commandrender emits a single TEXT commandLhTextTests.testAllLevelsUseTheirTokens
bash
swift test --filter LhTextTests

lh-ui native bloodline · iOS (Swift + SwiftUI)