Checkbox
Atomshadcn/ui, restyled with tokensChooses any number of options, or agrees to one thing. Submitted with the form.
components/atoms/checkbox.tsx- Use it for
- Multi-select lists, 'remember me', accepting terms.
- Not for
- A setting that applies at once (Switch) or one choice among several (RadioGroup).
States
Usage
import { Checkbox } from '@/components/atoms/checkbox';
<div className="flex items-center gap-2">
<Checkbox id="anonymous" checked={anonymous} onCheckedChange={setAnonymous} />
<Label htmlFor="anonymous">Send anonymously</Label>
</div>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | 'indeterminate' | — | Controlled state. Pair with onCheckedChange. |
| defaultChecked | boolean | — | Uncontrolled starting state. |
| onCheckedChange | (checked: boolean | 'indeterminate') => void | — | Called on every toggle. |
| disabled | boolean | false | Blocks changes; a peer Label dims with it. |
| aria-invalid | boolean | — | The error state. |
| name / value / required | string / string / boolean | — | Take part in a native form submission. |
Accessibility
- Toggled with Space.
- Announced as a checkbox; indeterminate is announced as “mixed”.