This page as markdown: /checkbox.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Checkbox

Status: stable

Square toggle (18px at rest, on the spacing scale) over Base UI's Checkbox. Checked/indeterminate/disabled states; controlled or uncontrolled; form-ready via the hidden native input.

Keywords: checkbox, boolean, multi select, form control

Usage

Use Checkbox for independent boolean choices or for selecting multiple options in a set.

Best practices

Props

Name Type Default Description
checked boolean — Controlled checked state. Pair with onCheckedChange. Omit for uncontrolled.
defaultChecked boolean false Initial checked state for an uncontrolled checkbox.
onCheckedChange (checked: boolean, eventDetails) => void — Fires when the checkbox is ticked or unticked. Note: Base UI passes a second eventDetails arg — not the common (checked) => void, so a single-arg handler must widen its signature.
indeterminate boolean false Mixed state (neither checked nor unchecked). Renders a dash instead of the check. For a "select all" box inside a CheckboxGroup, use parent instead and the group sets this for you.
parent boolean false Makes this the "select all" box of a CheckboxGroup that has allValues. It checks or clears every child, and shows the dash when only some are checked. Only works inside a CheckboxGroup.
disabled boolean false Ignores user interaction and dims the control.
name string — Field name for the hidden input on form submit.
value string — Value submitted with the form when checked. Inside a group-owned CheckboxGroup, it is the name the group's value array uses for this checkbox.
render ReactElement | (props, state) => ReactElement — Compose the root with another element through the Base UI render prop.
motion "full" | "subtle" | "off" "full" How much motion this component uses: full (default) inherits the app's policy, subtle keeps feedback and drops the flourish, off stills it. It can only turn motion down — it never overrides a reader's reduce-motion setting. Under subtle the tick fades in instead of drawing itself.

Tokens used

card, input, primary, primary-foreground, ring

Motion

Accessibility

Related

Examples

Default

import { Checkbox } from "@sableui/react"

<Checkbox defaultChecked />

Controlled

import { Checkbox } from "@sableui/react"

<Checkbox checked={value} onCheckedChange={setValue} />

Indeterminate

import { Checkbox } from "@sableui/react"

<Checkbox indeterminate />

Select all in a group

import { Checkbox, CheckboxGroup, Field } from "@sableui/react"

<CheckboxGroup allValues={["email", "sms"]} defaultValue={["email"]} className="gap-3"><Field label="All channels" orientation="horizontal"><Checkbox parent /></Field><Field label="Email" orientation="horizontal" className="ps-7"><Checkbox value="email" /></Field><Field label="SMS" orientation="horizontal" className="ps-7"><Checkbox value="sms" /></Field></CheckboxGroup>

With label

import { Checkbox, Field } from "@sableui/react"

<Field label="Remember me" orientation="horizontal"><Checkbox /></Field>