Checkbox
Turns an option on or off, with an indeterminate state for “some of these”. Square in every village, rounder in Konoha and Kiri, sharp in Iwa.
Installation
Or with the shadcn CLI, from the registry:
Usage
Indeterminate
indeterminate draws a dash, for a parent checkbox whose children are partly checked. Base UI's CheckboxGroup can
manage such a parent for you (parent on the parent checkbox).
Tones
tone colours the checked box: primary by default, neutral for the village's ink, and success, warning, info or destructive when the choice carries that meaning. Checked, the box takes the tone's edge, which holds 3:1 against the page: the colour itself, or for warning, whose amber is too light for that, its darker text colour.
Sizes
sm, default and lg follow the village's indicator sizes (--indicator-sm, --indicator-md, --indicator-lg), shared with Radio group and Slider's thumb.
Villages
The box takes the village's check radius and border width; checked, it fills with the nature's primary.
Accessibility
- A
role="checkbox"button witharia-checked(mixedwhen indeterminate), backed by a hidden input for forms. - Space toggles it; a linked label toggles it on click.
- Inside a Field, an invalid checkbox (a
requiredone left unchecked) turns destructive.
API reference
The props of Base UI's Checkbox root (checked, defaultChecked, onCheckedChange, indeterminate, name, value, required, disabled…), plus:
| Prop | Type | Default |
|---|---|---|
tone | "neutral" | "primary" | "success" | "warning" | "info" | "destructive" | "primary" |
size | "sm" | "default" | "lg" | "default" |
className | string |
checkboxVariants({ tone, size }) returns its classes.