DocsDocs

Checkbox

A choice people turn on or off on its own.

StableSince 1.0.0
On this page

Overview

Show code, IncludeArchived.tsx

Anatomy

  1. Checkbox

  2. Box

  3. Check

  4. Label

Show code, CheckboxAnatomy.tsx

Behaviour

States

Pressing the box or its label toggles it. A mixed box shows a dash. A checked box that is disabled takes the neutral fill rather than the accent, as a disabled button does.

Select all

A parent checks or clears all its children.

  • Checked when every child is.
  • Mixed when some are.
Show code, SelectAll.tsx

Adapting to width

The label wraps onto more lines, and the box stays centred beside it.

Show code, LongLabel.tsx

Rules

A checkbox says what it turns on, and a group of them has a name.

Use it when

  • Any number of options, each chosen on its own, such as which e-mails to receive
  • Agreeing to or including one option, applied when a form is sent, such as the terms
  • A parent that selects or clears a group, and shows when only some are chosen
DoName a group with a legend, so each choice reads in context.
Show code, NamedGroup.tsx

Labels

Write the label as the choice it turns on, in sentence case, so checking it means yes.

Accessibility

KeyAction
Tab, Shift+TabMoves to the next or previous checkbox.
SpaceChecks or unchecks it, and checks a mixed one.