Checkbox Group
Choose any number of related options.
Installation
pnpm dlx shadcn@4.18.0 add @siteplane/checkbox-groupComplete the one-time setup first. Registry JSON lists source files and dependencies.
For this page’s examples, also install:
pnpm dlx shadcn@4.18.0 add @siteplane/button @siteplane/checkbox @siteplane/fieldset @siteplane/form @siteplane/input @siteplane/labelField is installed with Input.
Usage
import { Checkbox } from "@/siteplane/components/checkbox";
import { CheckboxGroup } from "@/siteplane/components/checkbox-group";
import { Label } from "@/siteplane/components/label";
<CheckboxGroup aria-label="Notification channels" defaultValue={["email"]}>
<Label>
<Checkbox value="email" />
Email
</Label>
<Label>
<Checkbox value="sms" />
SMS
</Label>
</CheckboxGroup>;Composition
CheckboxGroup
├── Label + Checkbox
└── Label + CheckboxControlled selection
Pass value and onValueChange to own the selected values. Each checkbox needs a unique value; a disabled item keeps its state.
Parent checkbox
Add a checkbox with parent and list every item value in allValues. The parent checks or clears all items and shows the mixed state when only some are selected.
Form integration
Render the Field as a Fieldset so the legend names the group and the field’s name applies to every checkbox. The form submits one entry per checked value.
Card style
Use Label variant="card" for options that need a description; each card toggles its own checkbox.
Sizes
Set size on the group to size every checkbox; a checkbox’s own size still wins.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
Checkbox | sm | md | lg | xl | provider / lg | Shared item size. |
value / default | string[] | uncontrolled | Controlled or initial selection. |
on | (value, eventDetails) => void | unset | Selection change callback. |
all | string[] | unset | Every item value; required for a parent checkbox. |
disabled | boolean | false | Disables the group. |
The group places its options 8 px apart. A gap-* utility in className replaces that, so a horizontal group sets its own, for example className="flex-row gap-4".
CheckboxGroupProps and CheckboxGroupPrimitive are exported. Size is the only owned prop. Checkbox is installed transitively; mark the parent checkbox with its parent prop.
Other props, refs, validation and events follow Base UI CheckboxGroup. Styled parts accept string className.
Usage notes
Space toggles each focused checkbox. Give the group and each item an accessible label.