Checkbox
checkboxA single choice with a visible label wired to it for a screen reader. An indeterminate state for a select-all with only some rows picked, a description read as a description rather than folded into the name, a destructive variant, and a mark that draws itself in.
"use client";
import { useState } from "react";
import { Checkbox } from "@/components/forme/checkbox/checkbox";
const ROWS = ["main", "release/2.4", "feature/cache", "fix/typo"];
/** A controlled box with nowhere to go; the display-only rows use it. */
const noop = () => {};
export function CheckboxDemo() {
const [terms, setTerms] = useState(true);
const [updates, setUpdates] = useState(false);
const [picked, setPicked] = useState<string[]>(["main"]);
const [comments, setComments] = useState(true);
const [mentions, setMentions] = useState(true);
const [digest, setDigest] = useState(false);
const all = picked.length === ROWS.length;
const some = picked.length > 0 && !all;
return (
<div className="flex flex-col gap-8">
<div className="flex max-w-64 flex-col gap-3">
<Checkbox checked={terms} onCheckedChange={setTerms} label="Accept terms and conditions" />
<Checkbox checked={updates} onCheckedChange={setUpdates} label="Email me product updates" />
<Checkbox checked indeterminate onCheckedChange={noop} label="Select all (partial)" />
<Checkbox checked disabled onCheckedChange={noop} label="Disabled" />
</div>
<div className="flex w-full max-w-64 flex-col gap-3">
<Checkbox
checked={comments}
onCheckedChange={setComments}
label="Comments"
description="Replies on threads you started."
/>
<Checkbox
checked={mentions}
onCheckedChange={setMentions}
label="Mentions"
description="Whenever someone tags you by name."
/>
<Checkbox
checked={digest}
onCheckedChange={setDigest}
label="Weekly digest"
description="A summary of activity every Monday."
/>
<Checkbox
checked={false}
disabled
onCheckedChange={noop}
label="SMS alerts"
description="Add a phone number to enable."
/>
</div>
<div className="flex flex-col gap-3">
<Checkbox label="Delete every branch except main" destructive />
<Checkbox label="I understand this cannot be undone" destructive />
</div>
{/* The case indeterminate exists for: a parent that owns a list. */}
<fieldset className="grid max-w-sm gap-2.5 rounded-xl border border-border bg-card p-4">
<legend className="px-1 text-caption-1-medium text-muted-foreground">
Branches to keep
</legend>
<Checkbox
label="All branches"
checked={all}
indeterminate={some}
onCheckedChange={(checked) => setPicked(checked ? [...ROWS] : [])}
/>
<div className="ms-6 grid gap-2.5">
{ROWS.map((branch) => (
<Checkbox
key={branch}
label={branch}
checked={picked.includes(branch)}
onCheckedChange={(checked) =>
setPicked((current) =>
checked ? [...current, branch] : current.filter((entry) => entry !== branch),
)
}
/>
))}
</div>
</fieldset>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
Usage
import { Checkbox } from "@/components/forme/checkbox/checkbox";
<Checkbox label="Send me product updates" />When to use
Reach for it
- Options in a form that apply when it is submitted, and lists where several can be picked.
indeterminatefor a select-all that owns a list where only some rows are picked; it announces as mixed and clears on the next click.descriptionfor the one sentence the label cannot carry, which stays out of the accessible name.
Use something else
- Settings that apply instantly; use a
Switch. - One choice out of several; that is a
RadioGroup.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
Checkbox
A checkbox and its label are one component, not two.
| Prop | Type | Default | Description |
|---|---|---|---|
label | React.ReactNode | — | The visible label. Rendered beside the box and part of the click target. |
description | React.ReactNode | — | Supporting text under the label. Announced as the description rather than as part of the name, so the control is still "Include the raw data as CSV" and not that sentence plus an explanation. |
destructive | boolean | — | Renders destructive: a red box for a choice with consequences. |
Also takes every prop of Omit<CheckboxRootProps, "children">.
Accessibility
labelis a real<label for>attached to Base UI's underlying input, so the text is part of the click target — clicking it toggles the box.- The label and the description are separate elements tied with
aria-labelledbyandaria-describedby, so a screen reader reads the name and then the description instead of one run-on sentence. indeterminatesetsaria-checked="mixed", which is the state assistive technology expects for a partly selected group.
Motion
- The mark draws itself in, and changing between a tick and a dash replays the draw rather than swapping the path.
- Reduced motion keeps the fade and the draw's end state, and drops the scale and blur.
Related


Radio group
A choice of exactly one option. The selected dot travels between options on a spring, each option carries its own label and optional description, and arrow keys move the selection in the direction the options are laid out.
forms

Switch
A control for a setting that takes effect immediately, with a label that is part of the click target. The thumb travels on a weighty spring and stretches toward the far side while it is held; the track's colour flips on the frame it is clicked. Sized to sit in a row beside a control, not to read as a status badge.
forms

Poll
A question to vote on that turns into its results in place: bars grow to each share, the percentages roll and always total 100, and your choice is marked. Single or multiple choice, on real radios and checkboxes.
forms