Installation
npx logic2b@latest add checkboxUsage
import { Checkbox } from "@/components/ui/checkbox"
<Checkbox id="terms" />
API
| Prop | Type | Default |
|---|---|---|
checked / defaultChecked |
boolean | "indeterminate" — controlled/uncontrolled state |
— |
onCheckedChange |
(checked: boolean | "indeterminate") => void |
— |
disabled |
boolean |
false |
required |
boolean |
false |
name / value |
string — form field name and submitted value |
— |
Examples
With text
Pair the checkbox with a Label and helper description.
You can turn these off at any time in settings.
Disabled
Accessibility
- Renders a native-equivalent control with
role="checkbox"and reflects state viaaria-checked(including the mixed/indeterminate state). - Space toggles the focused checkbox; it is reachable and focusable with Tab.
- Associate a
LabelviahtmlFormatching the checkboxidso clicking the text toggles it.