Checkbox
A checkbox that sizes with density, with a label row as its hit area and a select-all parent.
Installation
npx shadcn@latest add @quireui/checkboxUsage
<CheckboxLabel description="One email per paid invoice.">
Email me when an invoice is paid
</CheckboxLabel>CheckboxLabel puts the box, its label and an optional description in one row, and the whole row toggles it, so the small box is never the only thing to aim for. It takes every Checkbox prop. Use Checkbox on its own where the label lives elsewhere, like a table header, and give it an aria-label.
Select all
Wrap the options in CheckboxGroup with allValues, and mark one CheckboxLabel as parent. It shows a dash while only some are checked. Clicking it selects everything, and when everything is already selected it clears them all. Disabled options keep their state either way.
Notification channels
<CheckboxGroup value={value} onValueChange={setValue} allValues={["email", "slack", "sms"]}>
<CheckboxLabel parent>All channels</CheckboxLabel>
<CheckboxLabel value="email">Email</CheckboxLabel>
<CheckboxLabel value="slack">Slack</CheckboxLabel>
<CheckboxLabel value="sms">Text message</CheckboxLabel>
</CheckboxGroup>States
Unchecked, checked, indeterminate (indeterminate), and disabled either way. The box is half a control's height, so it follows the density: 14px compact, 16px default, 20px comfortable, and larger on touch screens.
In a form
Inside a Field with a name, the box is submitted with the form, and required blocks the form until it is checked, with the error under the row and nothing below it moving.
Accessibility
Each box is read with its label, as checked or not. A parent is read as mixed while only some of its group are checked, and a description on CheckboxLabel is read after the label.
| Key | Action |
|---|---|
| Space | Toggles the focused checkbox. On a parent, checks or clears the whole group. |
| Tab / Shift+Tab | Moves between checkboxes. Each one is its own stop, like native checkboxes. |
Motion
The check pops in with the same quick scale as a menu opening, and only the fill colour fades. Toggling from the keyboard is instant, and reduced motion keeps only the fade.
API reference
Checkbox
Also takes every prop of Base UI's Checkbox.Root. Style it with [data-slot="checkbox"].
CheckboxLabel
A checkbox with its label and an optional description. The whole row is the hit area, so the small box is never the only thing to aim for.
Prop
Type
Style it with [data-slot="checkbox-label"].
CheckboxGroup
Holds a list of checkboxes and their combined value; a parent checkbox selects them all.
Also takes every prop of Base UI's CheckboxGroup. Style it with [data-slot="checkbox-group"].