Checkbox
Select or clear an independent option.
Installation
pnpm dlx shadcn@4.18.0 add @siteplane/checkboxComplete 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/form @siteplane/input @siteplane/labelField is installed with Input.
Usage
import { Checkbox } from "@/siteplane/components/checkbox";
import { Label } from "@/siteplane/components/label";
<Label>
<Checkbox />
Accept terms and conditions
</Label>;With description
Inside a Field, wrap the checkbox and its text in FieldLabel and add a FieldDescription. The Field connects the description to the checkbox, so it is announced separately from the name, and the description starts under the label text.
News about features and releases, at most once a month.
Disabled and invalid
disabled blocks interaction and leaves the value out of form data. aria-invalid only applies the invalid style; it does not validate.
Card style
Wrap the checkbox and its text in Label variant="card" so the whole card toggles the option. Label owns the shared hover, checked and disabled styles, so no extra state is needed.
Controlled state
Pass checked with onCheckedChange when your application owns the value; otherwise use defaultChecked.
Form integration
Inside a Field, the checkbox uses the field’s name. A checked box submits its value (on when none is set); an unchecked box submits nothing unless you set uncheckedValue.
Sizes
Omit size to inherit the Checkbox Group size, then the provider’s control size.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
size | sm | md | lg | xl | group / provider / lg | Control dimensions. |
children | ReactNode | unset | Rendered only for menu-item; the control supplies its own indicator. |
checked / default | boolean | unset / false | Controlled state or initial state. |
on | (checked, eventDetails) => void | unset | Called when the user changes the checked state. |
indeterminate | boolean | false | Shows the mixed state. A parent checkbox in Checkbox Group derives it automatically. |
disabled | boolean | false | Prevents interaction. |
name / value | string | unset | Native form participation. A checked box submits value (on if value is unset). |
unchecked | string | unset | Value submitted while the box is unchecked. |
CheckboxProps describes the size extension; CheckboxPrimitive is the Base UI namespace. Other props, including required, readOnly, parent, render and inputRef, follow Base UI Checkbox. Styled className is a string.
CheckboxSizeContext is exported with a null default; CheckboxGroup uses it to share size. checkboxVariants({ className }) returns the utility classes Checkbox adds beside its stylesheet. The look and the size come from the kit stylesheet through the attributes Checkbox renders; the helper does not resolve context or supply indicator behavior.
Usage notes
A checked box fills with the brand accent, and its check takes the text color for accent fills, --sp-rw-fg-on-accent, which a light brand sets dark (Theming).
Space changes the focused control. Supply a visible associated Label or an accessible name. Use Checkbox Group for multiple related choices, including a parent checkbox, and Radio Group for exactly one choice.