Skip to content

Text ​

A text component. It renders a single run of text by level, weight, tone, and alignment; every typography value comes from the typography tokens.

Spec source: lh-ui-core/specs/text.json · Golden cases: lh-ui-core/cases/text.json (5 cases, translated into xUnit tests)

Levels ​

Six levels map to the typography.fontSize.* tokens; the default level is base.

9:41Text levels
Extra large extraLarge
Large large
Medium medium
Base base
Small small
Extra small extraSmall

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

csharp
var text = new LhText
{
    Text = "Title text",
    Level = LhTextLevel.Large,
};

Weight and tone ​

Weight maps to the typography.fontWeight.* tokens; Tone maps to color.text.* (selected takes color.selected).

9:41Weight & tone
Bold bold
Secondary label secondary
Placeholder text placeholder
Selected state selected

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

Alignment ​

Align decides the horizontal placement inside the line-box width (not a design token; mapped to WinUI's TextAlignment).

9:41Alignment
Left-aligned start
Centered center
Right-aligned end

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

Light and dark themes ​

Toggle the site theme in the top-right corner and the text colors inside the simulator phone frame change with it; on a real device, switch via LhTheme.Apply(true).

9:41Dark text
Regular text regular
Secondary label secondary

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render; light/dark values are all taken from the core token snapshot

API ​

Props ​

PropDescriptionTypeDefault
TextText content (the spec's default slot)string""
LevelFont-size level; maps to typography.fontSize.*LhTextLevelBase
WeightFont weight; maps to typography.fontWeight.*LhTextWeightPrimary
ToneText tone; maps to color.text.* / color.selectedLhTextToneRegular
AlignHorizontal alignment (mapped to TextAlignment)LhTextAlignStart

LhTextLevel ​

ValueSize token
ExtraLargetypography.fontSize.extraLarge (20epx)
Largetypography.fontSize.large (18epx)
Mediumtypography.fontSize.medium (16epx)
Basetypography.fontSize.base (14epx)
Smalltypography.fontSize.small (13epx)
ExtraSmalltypography.fontSize.extraSmall (12epx)

LhTextWeight ​

ValueWeight token
Primarytypography.fontWeight.primary (400; mapped to Normal on this end)
Boldtypography.fontWeight.bold (600; mapped to SemiBold on this end)

LhTextTone ​

ValueColor token
Primarycolor.text.primary
Regularcolor.text.regular
Secondarycolor.text.secondary
Placeholdercolor.text.placeholder
Disabledcolor.text.disabled
Selectedcolor.selected

LhTextAlign ​

ValueWinUI mapping
StartTextAlignment.Left
CenterTextAlignment.Center
EndTextAlignment.Right

Token Reference ​

TokenUsage
typography.fontSize.{extraLarge…extraSmall}Six font sizes
typography.fontWeight.{primary,bold}Two font weights
typography.lineHeight.primaryLine height (line-box height = font size × line height)
typography.fontFamilyChinese-style serif font stack
color.text.{primary,regular,secondary,placeholder,disabled}Neutral tones
color.selectedSelected-state tone

Golden Case Reference ​

How the 5 assertions of cases/text.json map to xUnit tests (tests/LhTextTests.cs):

case idAssertionLocal test
default-level-uses-base-tokensThe default level consumes the base typography tokensDefault_Level_Uses_Base_Tokens
large-level-uses-large-tokenThe large level consumes the large font-size tokenLarge_Level_Uses_Large_Token
bold-weight-uses-bold-tokenBold consumes the bold weight tokenBold_Weight_Uses_Bold_Token
secondary-tone-uses-text-secondaryThe secondary tone takes the secondary text color tokenSecondary_Tone_Uses_Text_Secondary
render-emits-single-text-commandExactly one TEXT command is emittedRender_Emits_Single_Text_Command

Plus dark-mode suites: Dark_Colors_Come_From_Dark_Tokens / Dimensions_Are_Identical_In_Dark_Mode. Run: cd lh-ui-windows && dotnet test.

lh-ui native bloodline · Windows (C# + WinUI 3)