Checkbox
A control that allows the user to select one or more items from a set.
Installation
bash
npx shadcn@latest add checkboxImport
import { Checkbox } from "@/components/ui/checkbox"import { Label } from "@/components/ui/label"Default
With label
Checked
Disabled
Group
Props
PROPTYPEDEFAULTDESCRIPTION
checkedboolean | "indeterminate"—Controlled checked statedefaultCheckedbooleanfalseInitial state (uncontrolled)onCheckedChange(checked: boolean | "indeterminate") => void—Called on changedisabledbooleanfalseDisables the checkboxrequiredbooleanfalseMarks as required in a formnamestring—Form field nameAccessibility
- Space toggles the checkbox
- Always pair with a
Label - For a "select all" pattern, use indeterminate state when only some items are selected