Checkbox
FormBoolean toggle with checkmark indicator. Supports indeterminate state.
Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.
"use client";
import { Checkbox } from "@dashboardpack/core/components/ui/checkbox";
import { Label } from "@dashboardpack/core/components/ui/label";
import { useState } from "react";
export default function CheckboxExample() {
const [checked, setChecked] = useState(true);
return (
<div className="space-y-4">
<div className="flex items-center gap-3">
<Checkbox
id="check-updates"
checked={checked}
onCheckedChange={(value) => setChecked(value === true)}
/>
<Label htmlFor="check-updates">
Product updates {checked ? "enabled" : "disabled"}
</Label>
</div>
<div className="flex items-center gap-3">
<Checkbox id="check-mixed" checked="indeterminate" />
<Label htmlFor="check-mixed">Some projects selected</Label>
</div>
<div className="flex items-center gap-3">
<Checkbox id="check-disabled" disabled />
<Label htmlFor="check-disabled">Unavailable on this plan</Label>
</div>
</div>
);
}Usage
Use checkboxes for independent choices. Radix can return true, false, or indeterminate; normalize that value when storing a boolean.
import { Checkbox } from "@dashboardpack/core/components/ui/checkbox";Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.
API reference
Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.
| Prop | Type / Default | Description |
|---|---|---|
| checked | boolean | "indeterminate"Default: — | Controlled selection state. |
| defaultChecked | booleanDefault: — | Initial uncontrolled state. |
| onCheckedChange | (checked: boolean | "indeterminate") => voidDefault: — | Handle selection changes. |
| disabled | booleanDefault: false | Prevent changes. |