Checkbox

stable 1.5 kB
<hk-checkbox>

A checkbox with a real third state. A parent bound to a group reports indeterminate when its children disagree, which is the case most implementations skip.

#boolean#indeterminate

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
checkedbooleanfalseModel value. Two-way bindable.
indeterminatebooleanfalseRenders the mixed state. Independent of checked.
labelstring''Accessible label, rendered unless labelHidden is set.
disabledbooleanfalseBlocks interaction and dims the box.

Outputs

  • changedEventEmitter<boolean>

    Emits the new value on toggle.

Keyboard

  • Space Toggles the value
  • Tab Moves focus in and out

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-checkbox-size1remBox edge length.
--hk-checkbox-fill#dc2626Fill when checked or indeterminate.
--hk-checkbox-tick#ffffffTick and dash colour.

Accessibility

  • Sets aria-checked="mixed" for the indeterminate state rather than faking it with a class.
  • The whole label is the hit target, not just the 16px box.

More in Forms