Forms
Checkbox
A binary choice with a precise state.
States
A native checkbox with a custom box. The mark draws in when checked. Pair it with a label (and an optional description); the whole label is the click target.
When to use
- Independent yes/no choices, especially several at once: notification topics, filters, agreeing to terms.
- A list where any number of items can be selected, with a “select all” that shows a mixed state.
- Options that only take effect after a Save or Submit button.
Not for: a setting that applies immediately (use a switch), or choosing exactly one option (use a radio group).
Indeterminate
Set indeterminate on a parent when only some children are checked. It shows a dash and exposes aria-checked="mixed"; the next click checks it.
Sizes
Choice cards
variant="card" turns the whole card into the target and tints it with a ring when checked. Use it for options that need a price or a sentence of explanation.
API
Checkbox
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | — | Controlled state. |
| defaultChecked | boolean | false | Initial state when uncontrolled. |
| onCheckedChange | (checked: boolean) => void | — | Called when the user toggles the box. |
| indeterminate | boolean | false | Mixed state with a dash. Driven by you, not by clicks. |
| size | 'sm' | 'md' | 'lg' | 'md' | Box size: 16 / 20 / 24px. |
| variant | 'default' | 'card' | 'default' | Card makes the whole bordered card selectable. |
| label | ReactNode | — | Visible label. Without one, pass aria-label. |
| description | ReactNode | — | Secondary text; wired with aria-describedby. |
| invalid | boolean | — | Destructive border and aria-invalid. |
| className | string | — | Applied to the outer <label>. |
| ...props | InputHTMLAttributes | — | Forwarded to the <input>, including ref, name, value, disabled, required, form. |
Keyboard
| Key | Action |
|---|---|
| Space | Toggles the focused checkbox. |
| Tab | Moves focus to the next checkbox; each one is a tab stop. |
Accessibility
- Renders a real input type="checkbox", so role, state, form submission and autofill are native.
- The label wraps the input, so clicking the text toggles it and screen readers announce the name.
- Indeterminate maps to aria-checked="mixed"; invalid sets aria-invalid; the description is linked with aria-describedby.
- Keyboard focus shows a 3px ring around the box (or the card); pointer clicks do not.
Motion
- The check mark draws in with stroke-dashoffset (220ms, ease-out) as the box fills.
- Pressing the box scales it to .92 on the snappy spring.
- Reduced motion: the state changes, nothing animates.