Skip to content

Checkbox ​

A checkbox. Checked draws a check mark, indeterminate draws a dash, and the tap target covers the whole row (box + label area).

Spec source: lh-ui-core/specs/checkbox.json · Golden cases: lh-ui-core/cases/checkbox.json (6 cases, translated into xUnit tests)

Basic usage ​

9:41Checkbox basics
Unchecked
✓Checked
─Indeterminate

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

csharp
var checkbox = new LhCheckbox
{
    Label = "青花瓷 (ceramic blue)",
    Checked = true,
};
checkbox.Change += isChecked => { };

Sizes ​

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

9:41Checkbox sizes
✓Small
✓Medium
✓Large

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

States ​

When Disabled the checkbox does not respond to taps and the background / border / indicator / text all take the color.disabled.* tokens; Indeterminate is the indeterminate state (dash) and becomes checked after a tap.

9:41Checkbox states
✓Disabled checked
Disabled unchecked

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

API ​

Props ​

PropDescriptionTypeDefault
ChangeChecked-state callback; not fired when disabledevent Action<bool>—
CheckedWhether the checkbox is checkedboolfalse
IndeterminateWhether the checkbox is in the indeterminate state (dash indicator); becomes checked after a tapboolfalse
DisabledWhether the checkbox is disabled (does not respond to taps and renders the disabled style)boolfalse
LabelText label (drawn to the right of the box)string""
SizeBox size; maps to the checkbox.size.* tokensLhCheckboxSizeMedium

LhCheckboxSize ​

ValueSize token
Smallcheckbox.size.small (14epx)
Mediumcheckbox.size.medium (16epx)
Largecheckbox.size.large (18epx)

Token Reference ​

TokenUsage
checkbox.size.{small,medium,large}Three box sizes
checkbox.borderRadius / checkbox.borderWidthBox corner radius and border width
checkbox.checkWidthCheck / dash stroke width
checkbox.gapSpacing between the box and the label
color.primary.default / color.onPrimaryChecked / indeterminate background and indicator color
color.border.baseUnchecked border color
color.disabled.{bg,border,text}Disabled background / border / indicator
color.text.{primary,disabled}Label text color
typography.fontSize.base / fontFamilyLabel font size and font stack

Golden Case Reference ​

How the 6 assertions of cases/checkbox.json map to xUnit tests (tests/LhCheckboxTests.cs):

case idAssertionLocal test
tap-toggles-and-emits-onchangeAn unchecked tap turns it checkedTap_Toggles_And_Emits_OnChange
tap-checked-unchecksA checked tap unchecks itTap_Checked_Unchecks
disabled-blocks-changeThe disabled state is not interactiveDisabled_Blocks_Change
checked-uses-primary-tokensThe checked state consumes the primary tokensChecked_Uses_Primary_Tokens
unchecked-uses-border-tokenThe unchecked state consumes the border tokenUnchecked_Uses_Border_Token
indeterminate-becomes-checkedAn indeterminate tap turns it checkedIndeterminate_Becomes_Checked

Plus dark-mode suites: Dark_Colors_Come_From_Dark_Tokens / Dimensions_Are_Identical_In_Dark_Mode. Run: cd lh-ui-windows && dotnet test.

lh-ui native bloodline · Windows (C# + WinUI 3)