You agree to our terms of service and privacy policy.
Playground
Change the props and copy the code. The controls come from the component's TypeScript types.
You agree to our terms of service.
Props
import { Checkbox } from "@/components/ui/checkbox";<Checkbox label="Accept terms" description="You agree to our terms of service." />Installation
$ pnpm dlx shadcn@latest add @synccn/checkboxFirst time in this project? Connect synccn with one command.
Usage
import { Checkbox } from "@/components/ui/checkbox";<Checkbox label="Accept terms" defaultChecked />API reference
Generated from the component's TypeScript types, so it always matches the code.
- checked
boolean | "indeterminate"Controlled state.
- defaultChecked
boolean | "indeterminate"Default
falseInitial state when uncontrolled.
- onCheckedChange
(checked: boolean | "indeterminate") => voidCalled with the new state.
- label
React.ReactNodeClickable label.
- description
React.ReactNodeHelper text under the label.
- disabled
booleanPrevents changes.
- id
stringId for the control; generated if omitted.
- aria-label
stringAccessible name when there's no visible label (e.g. row checkboxes in a table).
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for Check, Minus
Keyboard
- SpaceToggle
Accessibility
- role checkbox with aria-checked, including the mixed (indeterminate) state.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: checkbox
- ARIA attributes: aria-checked, aria-label
- Shows a visible focus ring for keyboard users
- Labels are tied to their controls