Checkbox
Tri-state selection control. Supports the checked / unchecked / indeterminate states and can be disabled.
Spec source:
lh-ui-core/specs/checkbox.json· Golden cases:lh-ui-core/cases/checkbox.json(6 cases, translated into hypium tests)
Basic usage
checked is controlled; tapping toggles it and fires onChange with the new checked state.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
LhCheckbox({
checked: this.agreed,
label: 'Agree to the terms of service',
onChange: (checked: boolean) => { this.agreed = checked },
})Indeterminate and disabled
When indeterminate is true, a secondary-colored dash is shown; tapping the indeterminate state switches it to checked (golden case indeterminate-becomes-checked). disabled prevents toggling.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
API
Props
| Prop | Description | Type | Default |
|---|---|---|---|
checked | Whether checked | boolean | false |
indeterminate | Whether indeterminate; becomes checked after a tap | boolean | false |
disabled | Whether disabled; does not fire onChange when disabled | boolean | false |
label | Text label | string | '' |
size | Checkbox size, maps to the checkbox.size tokens | LhCheckboxSize | Medium |
onChange | Fired on tap with the new checked state | (checked: boolean) => void | Empty function |
LhCheckboxSize
| Value | size |
|---|---|
Small | checkbox.size.small (16vp) |
Medium | checkbox.size.medium (20vp) |
Large | checkbox.size.large (24vp) |
Checked state: background color.primary.default, check color.onPrimary, border in the primary color; unchecked state: transparent background, border color.border.base; indeterminate state: a secondary-colored dash; disabled state uses color.disabled.*.
Token reference
| Token | Purpose |
|---|---|
checkbox.size.{small,medium,large} | Three sizes |
checkbox.borderRadius / checkbox.borderWidth | Corner radius and border width (2 / 2vp) |
checkbox.checkWidth | Check-mark stroke width |
checkbox.gap | Gap between the box and the label (8vp) |
color.primary.default / color.onPrimary | Checked background / check color |
color.border.base | Unchecked border color |
color.text.secondary | Indeterminate dash color |
color.disabled.{bg,text,border} | Three disabled-state colors |
typography.fontSize.base | Label font size |
Golden case reference
How the 6 assertions in cases/checkbox.json map onto hypium tests (entry/src/test/Checkbox.test.ets):
| case id | Assertion | Local test |
|---|---|---|
tap-toggles-and-emits-onchange | A tap toggles and fires onChange | tap_toggles_checked |
tap-checked-unchecks | Tapping the checked state unchecks it | tap_checked_unchecks |
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 |
indeterminate-becomes-checked | Tapping the indeterminate state checks it | indeterminate_becomes_checked / indeterminate_uses_dash_mark |
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.

