Skip to content

Checkbox ​

A controlled checkbox that supports the indeterminate state and disabled.

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

States ​

Checked and indeterminate render a solid primary background with an onPrimary indicator (a checkmark or a dash); unchecked is outlined only.

9:41Checkbox

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

kotlin
var checked by remember { mutableStateOf(false) }
LhCheckbox(
  checked = checked,
  onCheckedChange = { checked = it },
  label = "同意协议",
)

Sizes ​

Three box sizes map to the checkbox.size.* tokens.

9:41Checkbox sizes

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

API ​

Props ​

PropDescriptionTypeDefault
checkedWhether the checkbox is checked (required)Boolean—
onCheckedChangeChecked-state change callback, carrying the new checked state(Boolean) -> Unit—
indeterminateWhether the checkbox is indeterminateBooleanfalse
disabledWhether the checkbox is disabledBooleanfalse
labelLabel textString?null
lhSizeBox sizeLhCheckboxSizeMedium
labelContentLabel content (overrides label; the spec's default slot)@Composable (() -> Unit)?null
modifierModifierModifierModifier

LhCheckboxSize ​

ValueSize token
Smallcheckbox.size.small (16dp)
Mediumcheckbox.size.medium (20dp)
Largecheckbox.size.large (24dp)

The tap target is the whole row (box + label): tapping the indeterminate state selects it; otherwise the checked state is toggled.

Token reference ​

TokenUsage
checkbox.size.{small,medium,large}Three box sizes
checkbox.borderRadius / checkbox.borderWidthBox corner radius and border width
checkbox.checkWidthCheckmark / dash stroke width
checkbox.gapGap between the box and the label
color.primary.default / color.onPrimaryChecked background / indicator color
color.border.baseUnchecked border color
color.disabled.{bg,border,text}The three disabled colors
color.text.primaryLabel color
typography.fontSize.baseLabel font size

Golden case reference ​

case idAssertionLocal test
tap-toggles-and-emits-onchangeA tap toggles the state and emits onChangeLhCheckboxTest.tap_unchecked_emits_true (Compose UI Test)
tap-checked-unchecksTapping the checked state unchecks itLhCheckboxTest.tap_checked_emits_false
indeterminate-becomes-checkedTapping the indeterminate state selects itLhCheckboxTest.tap_indeterminate_emits_true
disabled-blocks-changeThe disabled state does not triggerLhCheckboxTest.disabled_blocks_change
checked-uses-primary-tokensChecked consumes the primary tokensLhCheckboxDefaultsTest.checked_uses_primary_tokens
unchecked-uses-border-tokenUnchecked consumes the border tokenLhCheckboxDefaultsTest.unchecked_uses_border_token
bash
./gradlew :components:checkbox:test                            # JVM part
./gradlew :components:checkbox:connectedAndroidTest           # Interaction part (requires a device)

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