Skip to content

Checkbox

checkbox

A 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.

Install

$npxshadcnadd@forme/checkbox

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.
  • indeterminate for a select-all that owns a list where only some rows are picked; it announces as mixed and clears on the next click.
  • description for 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.

PropTypeDefaultDescription
labelReact.ReactNode—The visible label. Rendered beside the box and part of the click target.
descriptionReact.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.
destructiveboolean—Renders destructive: a red box for a choice with consequences.

Also takes every prop of Omit<CheckboxRootProps, "children">.

Accessibility

  • label is 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-labelledby and aria-describedby, so a screen reader reads the name and then the description instead of one run-on sentence.
  • indeterminate sets aria-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.