Skip to content

Checkbox

A form control for toggling individual options on or off. Supports checked, unchecked, and indeterminate states.

Preview

States

Error state

You must accept the terms to continue.

States

StateAppearance
UncheckedEmpty box with border
CheckedBrand-purple fill with white checkmark
IndeterminateBrand-purple fill with white dash
Disabled60% opacity, no interaction
Focus2 px brand-purple ring with 2 px offset
ErrorRed border

Props

PropTypeDefaultDescription
checkedbooleanfalseWhether the checkbox is checked
indeterminatebooleanfalseIndeterminate state (for "select all")
onChange(checked: boolean) => void--Change handler
labelstring--Visible label text
disabledbooleanfalseDisables interaction
errorbooleanfalseShows error border
namestring--Form field name

Code example

React

tsx
import { Checkbox } from '@thepace/lexicon/components';

<Checkbox label="Email notifications" checked onChange={setEmail} />
<Checkbox label="SMS notifications" />
<Checkbox label="I agree to the terms" error />

Vanilla HTML

html
<label class="lex-checkbox">
  <input type="checkbox" class="lex-checkbox__input" checked />
  <span>Email notifications</span>
</label>

<label class="lex-checkbox lex-checkbox--error">
  <input type="checkbox" class="lex-checkbox__input" />
  <span>I agree to the terms</span>
</label>

CSS class reference

ClassPurpose
.lex-checkboxWrapper label
.lex-checkbox__inputThe checkbox input
.lex-checkbox--disabledDisabled state
.lex-checkbox--errorError border

Accessibility

  • Uses a native <input type="checkbox"> for full keyboard and screen reader support.
  • Label wraps the input — no htmlFor required.
  • aria-invalid="true" when in error state.
  • Keyboard: Space toggles the checkbox.
  • Indeterminate state set via element.indeterminate = true in JavaScript.

Guidelines

Do

  • Use for independent options that can be toggled individually.
  • Use indeterminate state for "select all" headers in checkbox groups.
  • Group related checkboxes inside a <fieldset> with a <legend>.

Don't

  • Don't use for mutually exclusive options — use Radio instead.
  • Don't use as a toggle switch — use Toggle for instant on/off actions.

Released under the MIT License. A product by the pace.