Installation
npx logic2b@next add checkboxUsage
import { Checkbox } from "@/components/ui/checkbox"
<Checkbox id="terms" />
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.
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
Generated JSX
<Checkbox
defaultChecked
aria-label="Accept terms"
/>API reference
Generated from the public TypeScript exports in src/ui/checkbox.tsx.
Checkbox
ComponentProps: React.ComponentProps<typeof CheckboxPrimitive.Root>Accessibility contract
Machine-readable behavior and consumer responsibilities for checkbox.
- Support
- Primitive-managed
- Pattern
- checkbox
- Radix Checkbox
| Keys | Behavior |
|---|---|
| Enter Space | Activate the focused control. |
Built-in semantics
- Exposes role=checkbox and aria-checked, including the mixed state.
Consumer responsibilities
- Associate the control with a visible Label or aria-label.