Checkbox
An independent on/off choice. Use several for a set of options where any number may be chosen, and one on its own for consent.
Purpose
Each checkbox stands alone: ticking one says nothing about the others. When exactly one option must be chosen, use Radio group; when the choice takes effect immediately, use Switch.
Example
States
Unchecked, checked, indeterminate and disabled. A disabled checkbox keeps its mark so the current value stays readable.
Indeterminate
For a parent checkbox over a partially ticked set, pass checked="indeterminate" — a controlled
value, alongside true and false. The box fills --primary with a remove (minus) glyph, and
screen readers announce it as "mixed".
const [dependants, setDependants] = React.useState([true, false, true]);
const all = dependants.every(Boolean);
const none = dependants.every((d) => !d);
<Checkbox
id="all-dependants"
checked={all ? true : none ? false : "indeterminate"}
onCheckedChange={(next) => setDependants(dependants.map(() => next === true))}
/>
<Label htmlFor="all-dependants">Include all dependants</Label>Structure
| Property | Value |
|---|---|
| Box | 20px square (size-5), 5px radius |
| Border | 1px --input, --background fill, --shadow-1 |
| Checked | --primary fill and border, 16px check glyph in --primary-foreground |
| Indeterminate | same fill, 16px remove glyph |
| Focus | 2px --ring, offset 2px |
| Disabled | 50% opacity, not-allowed cursor |
Best practices
Do
- Pair every checkbox with a
LabelviahtmlFor, so the text is clickable too. - Word labels so ticked means yes — "Email me a copy", not "Do not email me".
- Use
checked="indeterminate"on a parent when only some of its children are ticked. - Use a single checkbox for consent — unticked must be a valid, submittable state.
Don't
- Use a checkbox for a setting that applies instantly — that is Switch.
- Use checkboxes for mutually exclusive options — that is Radio group.
- Pre-tick consent — it must be an explicit act.
- Leave indeterminate reachable by clicking — it is a display state; a click resolves it to on or off.
Accessibility & keyboard
- Radix renders a real button with
role="checkbox";aria-checkedreportstrue,falseormixed(indeterminate). - Pair every checkbox with a
Labelvia a matchingid— clicking the label toggles the box. - Focus shows a 2px
--ringoutline with offset — never remove it. - Keyboard: Space toggles; Tab moves between checkboxes.
Props
Checkbox is a styled re-export of the Radix Checkbox root — checked / onCheckedChange
(controlled) and defaultChecked (uncontrolled) accept true, false or "indeterminate", plus
disabled, required, name and value for forms. See the
Storybook prop tables for the
full generated API.