Skip to content

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:

9:41Radio group

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

typescript
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%).

9:41Radio sizes

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

API ​

Props ​

PropDescriptionTypeDefault
checkedWhether checkedbooleanfalse
disabledWhether disabled; does not fire onChange when disabledbooleanfalse
labelText labelstring''
valueThis option's value (the host maintains the group by it)string''
sizeRadio size, maps to the radio.size tokensLhRadioSizeMedium
onChangeFires (true) on the transition from unchecked to checked; not fired when already checked(checked: boolean) => voidEmpty function

LhRadioSize ​

Valuesize
Smallradio.size.small (16vp)
Mediumradio.size.medium (20vp)
Largeradio.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 ​

TokenPurpose
radio.size.{small,medium,large}Three outer-ring sizes
radio.ringWidthOuter ring border width (2vp)
radio.dotScaleRatio of the inner dot to the outer ring diameter (0.5 fraction)
radio.gapGap between the ring and the label (8vp)
color.primary.defaultChecked border and dot color
color.border.baseUnchecked border color
color.disabled.{text,border}Disabled-state colors
typography.fontSize.baseLabel font size

Golden case reference ​

How the 6 assertions in cases/radio.json map onto hypium tests (entry/src/test/Radio.test.ets):

case idAssertionLocal test
tap-unchecked-emits-onchangeTapping the unchecked state fires onChangeunchecked_is_interactive
tap-checked-keeps-checkedTapping the checked state does not firechecked_still_interactive_but_component_gates
disabled-blocks-changeDisabled state does not fire onChangedisabled_is_not_interactive
checked-uses-primary-tokensChecked state consumes the primary tokenschecked_uses_primary_tokens
unchecked-uses-border-tokenUnchecked state consumes the border tokenunchecked_uses_border_token
small-size-uses-small-tokenSmall uses the small size tokensmall_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.

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