Skip to content

Tag ​

A semantic-color tag that supports plain (outlined), fully rounded marks, and a close button.

Spec source: lh-ui-core/specs/tag.json · Golden cases: cases/tag.json (6 cases, translated into JVM unit tests + Compose UI Test)

Types ​

Six semantic types determine the background and text color.

9:41Tag types
DefaultSuccess
WarningDanger
Info

HTML mock preview (Android / Compose look), not an on-device render

kotlin
LhTag(type = LhTagType.success) { Text("成功") }

Plain ​

When plain is set, the tag has a transparent background with a semantic-color border and text.

9:41Tag plain
PrimarySuccess
Danger

HTML mock preview (Android / Compose look), not an on-device render

Size and mark ​

Three sizes map to the tag.height / tag.paddingHorizontal / tag.fontSize tokens; mark uses a fully rounded radius of half the height.

9:41Tag sizes
smallmediumlarge
MarkSuccess mark

HTML mock preview (Android / Compose look), not an on-device render

API ​

Props ​

PropDescriptionTypeDefault
textTag text (a convenience form; mutually exclusive with content)String?null
modifierModifierModifierModifier
typeSemantic typeLhTagTypeDefault
lhSizeSizeLhTagSizeMedium
plainWhether the tag is outlined (transparent background + semantic-color border)Booleanfalse
roundWhether the corners are fully rounded (half the height)Booleanfalse
closableWhether to show the close buttonBooleanfalse
onCloseClose callback; not triggered when closable is false(() -> Unit)?null
contentTag content (overrides text; the spec's default slot)@Composable (() -> Unit)?null

LhTagType ​

ValueBackground (non-plain)Border/text (plain)
Defaultcolor.background.default + color.border.base bordercolor.text.primary
Primarycolor.primary.defaultcolor.primary.default
Successcolor.success.defaultcolor.success.default
Warningcolor.warning.defaultcolor.warning.default
Dangercolor.danger.defaultcolor.danger.default
Infocolor.info.defaultcolor.info.default

LhTagSize ​

ValueheightpaddingHorizontalfontSize
Smalltag.height.small (20dp)tag.paddingHorizontal.small (8dp)tag.fontSize.small (12sp)
Mediumtag.height.medium (24dp)tag.paddingHorizontal.medium (10dp)tag.fontSize.medium (14sp)
Largetag.height.large (28dp)tag.paddingHorizontal.large (12dp)tag.fontSize.large (16sp)

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,success,warning,danger,info}.defaultSemantic background / border / text colors
color.onPrimaryNon-plain text color
color.disabled.{bg,text,border}The three disabled colors
spacing.xsGap between the close button and the text

Golden case reference ​

case idAssertionLocal test
default-type-renders-textThe default type takes a neutral background + primary text color + a base borderLhTagDefaultsTest.default_type_uses_neutral_tokens
primary-type-uses-primary-tokensThe primary type consumes the primary tokensLhTagDefaultsTest.primary_type_uses_primary_tokens
plain-uses-bg-tokensplain consumes the semantic light-background tokensLhTagDefaultsTest.plain_uses_bg_tokens
small-size-uses-small-tokensSmall consumes the small tokens (with a reverse assertion that large is not applied)LhTagDefaultsTest.small_size_uses_small_tokens
round-makes-radius-half-heightround makes the corner radius half the heightLhTagDefaultsTest.round_makes_radius_half_height
closable-tap-emits-oncloseTapping close triggers onCloseLhTagTest.closable_tap_emits_onClose (Compose UI Test)
bash
./gradlew :components:tag:test                             # JVM part
./gradlew :components:tag:connectedAndroidTest            # Interaction part (requires a device)

lh-ui native bloodline · Android (Kotlin + Compose)