Skip to content

Radio ​

A controlled radio. Tapping it again after selection does not deselect it (radio semantics).

Spec source: lh-ui-core/specs/radio.json · Golden cases: cases/radio.json (6 cases, translated into JVM unit tests + Compose UI Test)

States and radio groups ​

The component itself contains no group logic; mutual exclusion within a group is maintained by the host (use value to identify the item within the group).

9:41Radio

HTML mock preview (Android / Compose look), not an on-device render

kotlin
var selected by remember { mutableStateOf("a") }
listOf("选项一" to "a", "选项二" to "b").forEach { (text, value) ->
  LhRadio(
    checked = selected == value,
    onChange = { selected = value },
    label = text,
    value = value,
  )
}

Sizes ​

Three ring sizes map to the radio.size.* tokens; the inner dot diameter = size × radio.dotScale.

9:41Radio sizes

HTML mock preview (Android / Compose look), not an on-device render

API ​

Props ​

PropDescriptionTypeDefault
checkedWhether the radio is selected (required)Boolean—
onChangeTriggered when the radio goes from unchecked to checked, carrying checked = true(Boolean) -> Unit—
disabledWhether the radio is disabledBooleanfalse
labelLabel textString?null
valueRadio value (identifier within the group; the component itself carries no group logic)String?null
lhSizeRing sizeLhRadioSizeMedium
labelContentLabel content (overrides label; the spec's default slot)@Composable (() -> Unit)?null
modifierModifierModifierModifier

LhRadioSize ​

ValueSize tokenInner dot diameter
Smallradio.size.small (16dp)16dp × radio.dotScale (0.5)
Mediumradio.size.medium (20dp)20dp × radio.dotScale
Largeradio.size.large (24dp)24dp × radio.dotScale

The tap target is the whole row: it becomes selected and fires onChange(true) only when it is unchecked and not disabled.

Token reference ​

TokenUsage
radio.size.{small,medium,large}Three ring sizes
radio.ringWidthOuter ring stroke width
radio.dotScaleRatio of the inner dot diameter to the outer ring diameter (a fraction)
radio.gapGap between the ring and the label
color.primary.defaultSelected ring and dot color
color.border.baseUnchecked ring color
color.disabled.{border,text}Disabled border / dot / text colors
color.text.primaryLabel color
typography.fontSize.baseLabel font size

Golden case reference ​

case idAssertionLocal test
tap-unchecked-emits-onchangeTapping an unchecked radio triggers onChange(true)LhRadioTest.tap_unchecked_emits_onchange_true (Compose UI Test)
tap-checked-keeps-checkedTapping a checked radio does not triggerLhRadioTest.tap_checked_does_not_emit
disabled-blocks-changeThe disabled state does not triggerLhRadioTest.disabled_blocks_change
checked-uses-primary-tokensSelected consumes the primary tokensLhRadioDefaultsTest.checked_uses_primary_tokens
unchecked-uses-border-tokenUnchecked consumes the border tokenLhRadioDefaultsTest.unchecked_uses_border_token
small-size-uses-small-tokenSmall consumes the small size tokensLhRadioDefaultsTest.small_size_uses_small_token
bash
./gradlew :components:radio:test                              # JVM part
./gradlew :components:radio:connectedAndroidTest             # Interaction part (requires a device)

lh-ui native bloodline · Android (Kotlin + Compose)