Skip to content
Alpha

Hololink UI is under active development. Components, APIs and these docs may change without notice.

Holo Checkbox

The <holo-checkbox> component is a form-associated checkbox that supports checked, indeterminate, and disabled states.

Use it for:

  • Letting users select zero or more options from a list, or opt in to a single setting (“Remember me”).
  • Showing a mixed state for a parent of partly selected children (indeterminate).

Don’t use it for:

  • Choosing exactly one option from a set. Use Radio.
  • Settings that take effect immediately. Use Switch.
  • An action. Use Button.
<holo-checkbox label="Accept terms"></holo-checkbox> <holo-checkbox label="Accept terms" checked></holo-checkbox>
<holo-checkbox label="Select all" indeterminate></holo-checkbox>
<holo-checkbox label="Accept terms" disabled></holo-checkbox>

The component renders a native <input type="checkbox"> inside a <label>, so the role, state and name come from the browser. The visual box is aria-hidden. The label prop is the accessible name. required and disabled are applied to the native input, indeterminate sets the native indeterminate property, and the component is form-associated through ElementInternals (its value is submitted only while checked).

Key Action
Tab Moves focus to or from the checkbox
Space Toggles the checkbox
  • The focus ring is drawn on the visual box when the native input matches :focus-visible.
  • When required and unchecked, the form reports a validity error (“This field is required.”) anchored to the input.
  • Clicking the label text toggles the checkbox.

You provide:

  • A label. There is no other way to name the checkbox, so an unlabelled one has no accessible name.
  • Visible error text if you validate beyond required.
  • A group label (for example a <fieldset> with a <legend>) around related checkboxes.

Importing

import '@philbob-sideprojects/hololink-ui/holo-checkbox';

Properties

PropertyAttributeTypeDefaultDescription
checkedcheckedbooleanfalseWhether the checkbox is checked.
disableddisabledbooleanfalseIf true, the checkbox is disabled and non-interactive.
indeterminateindeterminatebooleanfalsePuts the checkbox in an indeterminate visual state (does not affect the submitted form value).
labellabelstring—The visible label text for the checkbox.
namenamestring—The form field name submitted with the owning form.
requiredrequiredbooleanfalseIf true, the owning form cannot submit unless the checkbox is checked.
valuevaluestring'on'The form value submitted when the checkbox is checked.

Events

EventDetailDescription
holoChangebooleanEmitted when the checked state changes.

CSS custom properties

PropertyDescription
--holo-checkbox-bgBackground color of the unchecked box.
--holo-checkbox-border-colorBorder color of the unchecked box.
--holo-checkbox-check-colorColor of the check mark and indeterminate bar.
--holo-checkbox-checked-bgFill and border color of the checked or indeterminate box.
--holo-checkbox-radiusCorner radius of the box.
--holo-checkbox-text-colorText color of the label.