Prototype Library

Checkbox

A custom box with checked, indeterminate, and disabled states, Space/Enter keyboard toggling, and an inlined Lucide check icon. Form-associated; emits a composed change event.

Inherited wc import '@esa/ecology/esa-checkbox';

Preview

<esa-checkbox label="Subscribe to updates" checked></esa-checkbox>

States

<esa-checkbox label="Unchecked"></esa-checkbox>
<esa-checkbox label="Checked" checked></esa-checkbox>
<esa-checkbox label="Indeterminate" indeterminate></esa-checkbox>
<esa-checkbox label="Disabled" disabled></esa-checkbox>
<esa-checkbox label="Disabled + checked" disabled checked></esa-checkbox>

Sizes

<esa-checkbox label="Extra small" size="xs" checked></esa-checkbox>
<esa-checkbox label="Small" size="sm" checked></esa-checkbox>
<esa-checkbox label="Medium" size="md" checked></esa-checkbox>
<esa-checkbox label="Large" size="lg" checked></esa-checkbox>

No label

Omit label for a bare box — supply an aria-label for an accessible name.

<esa-checkbox checked aria-label="Select row"></esa-checkbox>

Form participation

Checked boxes submit on under their name; unchecked boxes submit nothing.

<form>
  <esa-checkbox label="Subscribe" name="subscribe" checked></esa-checkbox>
  <button type="submit">Submit</button>
</form>

API

PropTypeDefaultDescription
label string '' Text rendered beside the box.
checked boolean false Whether the box is checked.
indeterminate boolean false Renders the mixed/partial state with a dash.
size 'xs' | 'sm' | 'md' | 'lg' 'md' Box and label size.
disabled boolean false Disables interaction.

Events

EventTypeDefaultDescription
change CustomEvent<{ checked: boolean }> Fired when toggled. Composed and bubbling; detail.checked is the new state.

Accessibility

  • The box has role="checkbox" with aria-checked reflecting checked or mixed (indeterminate).
  • Focusable via tabindex and toggles on Space or Enter.
  • aria-disabled and a -1 tabindex are applied when disabled.
  • Without a label, provide an aria-label for an accessible name.