Skip to content

Tag ​

A compact tag for marking and selection. Smaller than a button; supports semantic types, borders, a capsule radius, and a close button.

Spec source: lh-ui-core/specs/tag.json · Golden cases: lh-ui-core/cases/tag.json (6 entries, translated into XCTest, runnable on the macOS host)

Types ​

Six types determine the background and text colors. plain is the outlined light-background form (semantic light background + semantic border).

9:41Tag types
DefaultPrimarySuccess
WarningDangerInfo
Plain primaryPlain success

HTML mock preview (iOS / SwiftUI appearance), not an on-device render

swift
LhTag(text: "Primary", type: .primary)
LhTag(text: "Plain success", type: .success, plain: true)

Size and radius ​

Three sizes map to the tag.height / paddingHorizontal / fontSize tokens; round swaps the corner radius for half the height (a capsule).

9:41Tag sizes
SmallMediumLarge
SquareRound

HTML mock preview (iOS / SwiftUI appearance), not an on-device render

Closable ​

closable shows a close button on the right whose tap fires onClose (golden case closable-tap-emits-onclose).

9:41Tag close
ClosableClosable

HTML mock preview (iOS / SwiftUI appearance), not an on-device render

swift
LhTag(text: "Closable", type: .primary, closable: true) {
  // onClose
}

API ​

Props ​

PropDescriptionTypeDefault
textTag textString—
typeTag type, determines the background and text colorsLhTagType.default
lhSizeTag size, mapped to the size tokensLhTagSize.medium
plainWhether to use the outlined light-background formBoolfalse
roundWhether to use a capsule radius (radius = height / 2)Boolfalse
closableWhether to show a close buttonBoolfalse
onCloseClose-button tap callback(() -> Void)?nil

LhTagType ​

ValueBackgroundText color
.defaultcolor.background.default + color.border.base bordercolor.text.primary
.primarycolor.primary.defaultcolor.onPrimary
.successcolor.success.defaultcolor.onPrimary
.warningcolor.warning.defaultcolor.onPrimary
.dangercolor.danger.defaultcolor.onPrimary
.infocolor.info.defaultcolor.onPrimary

When plain = true: the background takes color.<type>.bg, while the border and text take color.<type>.default (the .default type ignores plain — golden case default-type-renders-text).

LhTagSize ​

ValueheightpaddingHorizontalfontSize
.smalltag.height.small (20pt)tag.paddingHorizontal.small (8pt)tag.fontSize.small (12pt)
.mediumtag.height.medium (24pt)tag.paddingHorizontal.medium (12pt)tag.fontSize.medium (13pt)
.largetag.height.large (28pt)tag.paddingHorizontal.large (16pt)tag.fontSize.large (14pt)

Token Reference ​

TokenPurpose
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.borderWidthDefault radius (follows radius.small) and border width
tag.gapGap between the text and the close button (follows spacing.xs)
color.{primary,success,warning,danger,info}.{default,bg}Semantic-type backgrounds and outlined light backgrounds
color.onPrimarySemantic-type text color
color.background.default / color.text.primary / color.border.baseThe three default-type colors

Golden Case Mapping ​

case idAssertionLocal test
default-type-renders-textThe default type uses a neutral background / text and ignores plaintestDefaultTypeUsesNeutralTokens / testDefaultTypeIgnoresPlain
primary-type-uses-primary-tokensThe primary type consumes primary and onPrimarytestPrimaryTypeUsesPrimaryTokens
plain-uses-bg-tokensplain consumes the semantic bg and the semantic bordertestPlainUsesBgTokens
small-size-uses-small-tokensThe small size consumes the small size tokenstestSmallSizeUsesSmallTokens
round-makes-radius-half-heightThe round radius == height / 2testRoundMakesRadiusHalfHeight
closable-tap-emits-oncloseThe close button fires onClosetestClosableTagInitAndRender (gesture assertions need a simulator)

Plus dedicated dark-mode tests: testDarkColorsComeFromDarkTokens / testPlainInDarkUsesDarkBgTokens / testDimensionsAreIdenticalInDarkMode.

bash
swift test --filter LhTagTests    # Runs on the macOS host, no simulator required

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