Radio
Radio atom. The component itself carries no group logic — the host maintains the radio group (value + checked).
Spec source:
lh-ui-core/specs/radio.json· Golden cases:lh-ui-core/cases/radio.json(6 cases, translated into hypium tests)
Basic usage
onChange(true) fires on the transition from unchecked to checked; tapping an already-checked radio does not fire (golden case tap-checked-keeps-checked). The radio group is maintained by the host:
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
LhRadio({
label: 'Option one',
value: 'a',
checked: this.picked === 'a',
onChange: () => { this.picked = 'a' },
})Sizes
Three sizes map to the radio.size tokens; the inner dot scales proportionally by radio.dotScale (50%).
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
API
Props
| Prop | Description | Type | Default |
|---|---|---|---|
checked | Whether checked | boolean | false |
disabled | Whether disabled; does not fire onChange when disabled | boolean | false |
label | Text label | string | '' |
value | This option's value (the host maintains the group by it) | string | '' |
size | Radio size, maps to the radio.size tokens | LhRadioSize | Medium |
onChange | Fires (true) on the transition from unchecked to checked; not fired when already checked | (checked: boolean) => void | Empty function |
LhRadioSize
| Value | size |
|---|---|
Small | radio.size.small (16vp) |
Medium | radio.size.medium (20vp) |
Large | radio.size.large (24vp) |
Checked state: the outer ring's border is color.primary.default and the inner dot is the same color, with a diameter = outer ring size × radio.dotScale; unchecked state's border is color.border.base; disabled state uses color.disabled.*.
Token reference
| Token | Purpose |
|---|---|
radio.size.{small,medium,large} | Three outer-ring sizes |
radio.ringWidth | Outer ring border width (2vp) |
radio.dotScale | Ratio of the inner dot to the outer ring diameter (0.5 fraction) |
radio.gap | Gap between the ring and the label (8vp) |
color.primary.default | Checked border and dot color |
color.border.base | Unchecked border color |
color.disabled.{text,border} | Disabled-state colors |
typography.fontSize.base | Label font size |
Golden case reference
How the 6 assertions in cases/radio.json map onto hypium tests (entry/src/test/Radio.test.ets):
| case id | Assertion | Local test |
|---|---|---|
tap-unchecked-emits-onchange | Tapping the unchecked state fires onChange | unchecked_is_interactive |
tap-checked-keeps-checked | Tapping the checked state does not fire | checked_still_interactive_but_component_gates |
disabled-blocks-change | Disabled state does not fire onChange | disabled_is_not_interactive |
checked-uses-primary-tokens | Checked state consumes the primary tokens | checked_uses_primary_tokens |
unchecked-uses-border-token | Unchecked state consumes the border token | unchecked_uses_border_token |
small-size-uses-small-token | Small uses the small size token | small_size_uses_small_token / dot_size_scales_with_size_token |
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.

