Checkbox
An independent yes/no. Several of them are several separate questions.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
An independent yes/no. Several of them are several separate questions.
Import
import { Checkbox } from "@ir/ui";Watch out
- One departure from the Figma file:
Variants
| Axis | Options | Default |
|---|---|---|
size | sm · md | md |
Do and don't
Use Radio for one-of-many, Checkbox for any-of-many.
Don't — Use checkboxes for a choice where only one answer is allowed.
A checkbox says each option is an independent question. If ticking one should untick another, the control is lying about the shape of the choice.
Use Switch for an immediate change, Checkbox for something a Save button confirms.
Don't — Use a Checkbox for something that takes effect immediately.
A checkbox reads as a form value — it has been marked, not applied. A switch reads as a live setting. Getting these the wrong way round is how people click Save on a page that already saved.
Derive it — indeterminate means some children are ticked, never a third thing to choose.
Don't — Let someone click a parent checkbox into the indeterminate state.
Indeterminate is a report, not an option. A three-way cycle on click leaves people unable to tell what they just asked for.
Wrap it in Field, or pair it with a real label.
Don't — Leave the label unassociated so only the 20px box is clickable.
A 20px target is below every touch guideline, and the label is the part people aim at. Associating it makes the whole phrase clickable.
Label the positive and let the tick mean yes — "Send notifications".
Don't — Label it with a negative — "Do not send notifications".
A ticked box next to a negative is a double negative, and people have to read it twice to work out what is on.
Mute it, so disabled reads as disabled whether ticked or not.
Don't — Leave a disabled checked box painted like a live one.
A checked box at full strength invites a click that does nothing. This was a real defect in the Figma component, found while building this one.
Accessibility
- Radix renders a real button with role=checkbox and aria-checked, including "mixed" for indeterminate — the tri-state is announced, not just drawn.
- Space toggles; the label is a click target once associated through Field.
- aria-invalid colours the box and the focus ring together, so the failure does not depend on noticing one thin border.
Where it is drawn
Figma — structure from figma, measurements from shadcn.