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.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
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.
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 ◆.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
API
Props
| Prop | Description | Type | Default |
|---|---|---|---|
name | Icon name (resolved by the local icon system; unregistered names fall back to ◆) | string | '' |
size | Icon size, maps to the icon.size tokens | LhIconSize | Medium |
tone | Semantic color tone, decides the glyph color | LhIconTone | Default |
onClick | Tap callback | () => void | Empty function |
LhIconSize
| Value | size |
|---|---|
Small | icon.size.small (16vp) |
Medium | icon.size.medium (20vp) |
Large | icon.size.large (24vp) |
LhIconTone
| Value | Glyph color |
|---|---|
Default | color.text.primary |
Primary | color.primary.default |
Success | color.success.default |
Warning | color.warning.default |
Danger | color.danger.default |
Info | color.info.default |
Regular | color.text.regular |
Secondary | color.text.secondary |
Token reference
| Token | Purpose |
|---|---|
icon.size.{small,medium,large} | Three sizes |
color.text.primary | Default tone |
color.text.regular / color.text.secondary | Regular / secondary tones |
color.{primary,success,warning,danger,info}.default | Semantic tones |
Golden case reference
How the 5 assertions in cases/icon.json map onto hypium tests (entry/src/test/Icon.test.ets):
| case id | Assertion | Local test |
|---|---|---|
click-emits-onclick | A 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-primary | Default tone uses the primary text color | default_tone_uses_text_primary |
primary-tone-uses-primary-token | Primary tone uses the primary color token | primary_tone_uses_primary_token |
small-size-uses-small-token | Small uses the small size token | small_size_uses_small_token |
render-emits-icon-command | Rendering emits an icon command | No 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.

