Checkbox
Picks any number of options from a list, or confirms a single statement. The check draws itself in; the box gives a small press.
Install
npx shadcn@latest add @nelumbo/checkboxStates
Hover shows a 40px halo, which is also the click target, so the small box is easy to hit.
unchecked
checked
indeterminate
error
error checked
disabled
disabled checked
brand
Select all
A parent checkbox shows indeterminate while only some children are checked. Clicking it checks or clears them all.
Validation
Set aria-invalid and link a message with aria-describedby. Try submitting without checking the box.
Usage
import { Checkbox } from "@/components/ui/checkbox"<label className="flex items-center gap-3"> <Checkbox checked={remember} onCheckedChange={(v) => setRemember(v === true)} /> Remember me</label>Props
Other props go to Radix Checkbox (checked, defaultChecked, onCheckedChange, name, required…).
| Prop | Type | Default | Notes |
|---|---|---|---|
checked | boolean | "indeterminate" | Controlled state | |
color | "auto" | "neutral" | "brand" | "auto" | |
aria-invalid | boolean | Error color |