Skip to content

Tag ​

A tag for marking and selection. It supports six semantic types, three sizes, a plain (outlined) form, a round (pill) form, and a closable form.

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

Types ​

Six types determine the background, text color, and border color.

9:41Tag types
DefaultPrimarySuccess
WarningDangerInfo

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

csharp
var tag = new LhTag
{
    Text = "Primary",
    Type = LhTagType.Primary,
};

Plain and round ​

When Plain is true the tag switches to a light semantic background + semantic text + semantic border; when Round is true the corner radius takes half the height (pill form, paired with the tag.borderRadius token).

9:41Plain & round
PlainPlainPlain
RoundRound plain

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

Sizes and close ​

Three sizes map to the tag.height / paddingHorizontal / fontSize tokens; when Closable is true a close glyph is drawn on the right, and tapping it fires the Close event.

9:41Sizes & close
SML
Closable ✕

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

csharp
var tag = new LhTag
{
    Text = "Closable",
    Type = LhTagType.Primary,
    Closable = true,
};
tag.Close += () => { /* Close glyph tapped */ };

Light and dark themes ​

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

9:41Dark tags
PrimaryPlain

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
CloseFired when the close glyph is tapped (requires Closable to be true)event Action—
TextTag text content (the spec's default slot)string""
TypeSemantic type; determines the background, text color, and border colorLhTagTypeDefault
SizeTag size; maps to the size tokensLhTagSizeMedium
PlainWhether to use the light-background outlined formboolfalse
RoundWhether to use the pill form (corner radius is half the height)boolfalse
ClosableWhether to show the close glyphboolfalse

LhTagType ​

ValueSolid backgroundLight background (plain)Text color
Defaultcolor.background.defaultSamecolor.text.primary
Primarycolor.primary.defaultcolor.primary.bgcolor.onPrimary / color.primary.default
Successcolor.success.defaultcolor.success.bgcolor.onPrimary / color.success.default
Warningcolor.warning.defaultcolor.warning.bgcolor.onPrimary / color.warning.default
Dangercolor.danger.defaultcolor.danger.bgcolor.onPrimary / color.danger.default
Infocolor.info.defaultcolor.info.bgcolor.onPrimary / color.info.default

LhTagSize ​

ValueheightpaddingHorizontalfontSize
Smalltag.height.small (20epx)tag.paddingHorizontal.small (8epx)tag.fontSize.small (11)
Mediumtag.height.medium (24epx)tag.paddingHorizontal.medium (12epx)tag.fontSize.medium (12)
Largetag.height.large (28epx)tag.paddingHorizontal.large (16epx)tag.fontSize.large (13)

Token Reference ​

TokenUsage
tag.height.{small,medium,large}Three heights
tag.paddingHorizontal.{small,medium,large}Three horizontal paddings
tag.fontSize.{small,medium,large}Three font sizes
tag.borderRadius / tag.borderWidthCorner radius and border width
color.primary.default / color.onPrimaryPrimary type background / text
color.{success,warning,danger,info}.{default,bg}Semantic type solid / light backgrounds
color.background.default / color.text.primary / color.border.baseThe default type's three colors
spacing.xsSpacing between the close glyph and the text
typography.fontFamilyChinese-style serif font stack

Golden Case Reference ​

How the 6 assertions of cases/tag.json map to xUnit tests (tests/LhTagTests.cs):

case idAssertionLocal test
default-type-renders-textThe default type uses a neutral background / text / borderDefault_Type_Renders_Text
primary-type-uses-primary-tokensThe primary type consumes the primary tokensPrimary_Type_Uses_Primary_Tokens
plain-uses-bg-tokensThe plain form consumes the light semantic background tokensPlain_Uses_Bg_Tokens
small-size-uses-small-tokensSmall consumes the small size tokensSmall_Size_Uses_Small_Tokens
round-makes-radius-half-heightThe pill form's corner radius is half the heightRound_Makes_Radius_Half_Height
closable-tap-emits-oncloseTapping the close glyph fires onCloseClosable_Tap_Emits_OnClose

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)