Checkbox
Checkbox base prototype
The Checkbox base prototype provides checked, unchecked, disabled, and indeterminate interactions on top of Toggle semantics.
Anatomy
Section titled “Anatomy”Checkbox is split into root and indicator parts connected through the anatomy system.
- Root (
base-checkbox-root) manages Toggle state (checked,checkedChange), disabled behavior, and the additionalindeterminatestate. - Indicator (
base-checkbox-indicator) reads the rootcheckedandindeterminatestates through anatomy runtime access and reflects them for rendering. It does not own checkbox state.
The base-checkbox anatomy family uses a contains relation from root to indicator. A checkbox is expected to have at least one indicator, and may have more than one indicator when multiple visual surfaces need the same indicator semantics.
In the Web Components preview runtime, prototype IDs are registered with a wc- tag prefix: wc-base-checkbox-root and wc-base-checkbox-indicator.
Indeterminate Behavior
Section titled “Indeterminate Behavior”indeterminate may be uncontrolled via defaultIndeterminate or controlled via indeterminate.
When an enabled indeterminate checkbox is pressed:
checkedfollows the normalasToggle()checked behavior and emitscheckedChange.- The root requests
indeterminate: falseby emittingindeterminateChange. - If
indeterminateis uncontrolled, the root also clears its internal indeterminate state. - If
indeterminateis controlled, the external owner must handleindeterminateChangeand passindeterminate={false}back in.
Disabled checkboxes do not change checked or indeterminate state on press.