Skip to content

Icon ​

Icon component. Resolves an icon name into a glyph through the local icon system, supporting sizes and semantic color tones.

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

Device-side landing note

The HarmonyOS side currently uses unicode glyphs as placeholders (LhIconTokens.glyphFor); production builds should swap in SymbolGlyph or vector assets. This matches button's Text('◆') placeholder strategy. Registered icon names are listed in the "Icon names" section below.

Sizes ​

Three sizes map to the icon.size tokens.

9:41Icon sizes
⌕⌕⌕

HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render

typescript
LhIcon({ name: 'search', size: LhIconSize.Large })

Color tones ​

tone decides the glyph color and corresponds one-to-one with the semantic color tokens; the default tone uses color.text.primary.

9:41Icon tones
✓ Default✓ Primary✓ Success
⚠ Warning✕ Dangerℹ Info
✓ Regular✓ Secondary

HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render

Icon names ​

Icon names and glyphs currently registered in glyphFor: search ⌕, refresh ↻, check ✓, close ✕, warning ⚠, info ℹ, back ←, more ⋯, star ★, edit ✎, delete ⌫, plus +, minus -, arrow →. Unregistered names fall back to ◆.

9:41Registered icons
⌕↻✓✕⚠ℹ←⋯
★✎⌫+-→

HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render

API ​

Props ​

PropDescriptionTypeDefault
nameIcon name (resolved by the local icon system; unregistered names fall back to ◆)string''
sizeIcon size, maps to the icon.size tokensLhIconSizeMedium
toneSemantic color tone, decides the glyph colorLhIconToneDefault
onClickTap callback() => voidEmpty function

LhIconSize ​

Valuesize
Smallicon.size.small (16vp)
Mediumicon.size.medium (20vp)
Largeicon.size.large (24vp)

LhIconTone ​

ValueGlyph color
Defaultcolor.text.primary
Primarycolor.primary.default
Successcolor.success.default
Warningcolor.warning.default
Dangercolor.danger.default
Infocolor.info.default
Regularcolor.text.regular
Secondarycolor.text.secondary

Token reference ​

TokenPurpose
icon.size.{small,medium,large}Three sizes
color.text.primaryDefault tone
color.text.regular / color.text.secondaryRegular / secondary tones
color.{primary,success,warning,danger,info}.defaultSemantic tones

Golden case reference ​

How the 5 assertions in cases/icon.json map onto hypium tests (entry/src/test/Icon.test.ets):

case idAssertionLocal test
click-emits-onclickA tap fires the callback (on-device this is the onClick prop)glyph_maps_registered_name (aligned to a declarative callback on the device side)
default-tone-uses-text-primaryDefault tone uses the primary text colordefault_tone_uses_text_primary
primary-tone-uses-primary-tokenPrimary tone uses the primary color tokenprimary_tone_uses_primary_token
small-size-uses-small-tokenSmall uses the small size tokensmall_size_uses_small_token
render-emits-icon-commandRendering emits an icon commandNo counterpart on the device side (declarative rendering; see glyph_maps_registered_name / glyph_falls_back_for_unknown_name for the glyph mapping)

Plus dark-mode specifics: dark_colors_come_from_dark_tokens / dimensions_are_identical_in_dark_mode. To run: in DevEco Studio, right-click entry/src/test → Run Tests.

lh-ui native bloodline · HarmonyOS (ArkTS + ArkUI)