Checkbox
One option to tick or leave: alone as a yes or no, or in a list where any number can be picked. Two sizes, with a label, a description and a third state, “some”, for a Select all.
<CheckboxGroup defaultValue={["failures"]} aria-label="Email me about"> <Checkbox value="failures">Run failures</Checkbox> <Checkbox value="quota">Quota reached</Checkbox> <Checkbox value="summary" description="One email on Monday.">Weekly summary</Checkbox></CheckboxGroup>Installation
import { Checkbox, CheckboxGroup } from "@dome-systems/ds-dashboard/components";Usage
import { Checkbox, CheckboxGroup } from "@dome-systems/ds-dashboard/components";<Checkbox defaultChecked>Run failures</Checkbox>Anatomy
- 1 — Box. Off, the Input: its fill and a 1px ring. On and "some", the primary button. Its edge is a shadow, never a border.
- 2 — Glyph. A check when ticked, a bar for "some", in the primary button's text color.
- 3 — Label. The text, medium or regular. The box is centered on its first line. A press on it ticks the box.
- 4 — Info icon. Opens a tooltip on hover and on focus. A press on it does not tick the box.
- 5 — Badge. On the label's line. The line wraps when it runs out of room.
- 6 — Description. A line of help, 2px under the label, in the secondary text color.
| Size | Box | Corners | Check | Text | Box to text | Info icon | Hit area |
|---|---|---|---|---|---|---|---|
md | 14px | 4px | 11px | label-2, 13px | 8px | 12px | 26px |
sm | 12px | 3px | 9px | label-3, 12px | 6px | 11px | 24px |
Sizes
One size sets the control and its text together. md, the default, is a 14px box with 13px text, 8px apart. sm is a 12px box with 12px text, 6px apart. The description and the info icon follow.
<Checkbox defaultChecked>Run failures</Checkbox><Checkbox size="sm" defaultChecked>Run failures</Checkbox>Unchecked, checked and some
Off, the box is the Input: its fill and its ring. On, it is the primary button, with a check. defaultChecked says where the box starts. When a box is ticked, the check is drawn left to right in 0.2s, as a hand writes it. It never draws on the page's first paint, and not at all under reduced motion. indeterminate is the third state, "some": a bar in place of the check, for a box that stands for others and has only part of them ticked. A box on its own is ticked or it is not. A parent box in a group works it out, so you rarely set it yourself.
<Checkbox>Quota reached</Checkbox><Checkbox defaultChecked>Quota reached</Checkbox><Checkbox indeterminate>Select all</Checkbox>Controlled
checked with onCheckedChange hands the state to the page. The handler gets a boolean, never "some".
const [checked, setChecked] = useState(false);
<Checkbox checked={checked} onCheckedChange={setChecked}> Include archived agents</Checkbox><Badge color={checked ? "success" : "neutral"}>{checked ? "Included" : "Left out"}</Badge>Label weight
The text after the box is its label: children. It is medium by default. weight="regular" is for long lists.
<Checkbox defaultChecked>Run failures</Checkbox><Checkbox weight="regular" defaultChecked>Run failures</Checkbox>Description
description is a line of help under the label, in the secondary text color. A press on it ticks the box, as a press on the label does.
<Checkbox defaultChecked description="One email on Monday, with the week's runs and failures."> Weekly summary</Checkbox>Badge
badge sits after the label, on its line. You set the badge's size yourself: md beside an md label, sm beside an sm one.
<Checkbox badge={<Badge color="fuchsia" size="md">Preview</Badge>}>Anomaly alerts</Checkbox><Checkbox size="sm" badge={<Badge color="fuchsia" size="sm">Preview</Badge>}>Anomaly alerts</Checkbox>Info icon
iconTooltip puts an info icon after the label: 12px beside md text, 11px beside sm. Its tooltip opens on hover and on focus, and Tab reaches it. A press on it never ticks the box.
<Checkbox iconTooltip="The gateway signs in as itself, with no stored key.">Use workload identity</Checkbox>The box alone
With no children the Checkbox is the box and nothing else, for a place that names it: a table row, a list header. Give it an aria-label, since nothing else names it for a screen reader. It can be pressed 6px past each edge (26px across at md, 24px at sm), so it needs no padding added to be easy to hit.
<Checkbox aria-label="Select all rows" indeterminate /><Checkbox aria-label="Select billing-sync" defaultChecked />Disabled
disabled draws the box at half strength, with the not-allowed cursor over the box and its text. The box does not tick, and Tab skips it.
<Checkbox disabled>Quota reached</Checkbox><Checkbox disabled defaultChecked>Quota reached</Checkbox>Invalid
aria-invalid gives the box the Input's error edge, and its error band on focus. The words that say what is wrong belong to a Field.
<Checkbox aria-invalid>I understand this deletes the workspace</Checkbox><Checkbox aria-invalid defaultChecked>I understand this deletes the workspace</Checkbox>In a group
CheckboxGroup stacks two boxes or more, 8px apart, and holds what is ticked as a list of each box's value. Name the group with aria-label, or put it in a Field. disabled on the group disables every box in it.
<CheckboxGroup defaultValue={["failures", "summary"]} aria-label="Email me about"> <Checkbox value="failures">Run failures</Checkbox> <Checkbox value="quota">Quota reached</Checkbox> <Checkbox value="summary">Weekly summary</Checkbox></CheckboxGroup>Select all
A box with parent on top of a group stands for the whole group. Give the group allValues, every value it holds, and control it with value and onValueChange. The parent is unchecked with nothing ticked, "some" with part, and checked with all. A press on a "some" parent ticks everything, the next press clears everything, and the one after brings back what was ticked before.
const ALL = ["failures", "quota", "summary"];const [picked, setPicked] = useState(["failures"]);
<CheckboxGroup value={picked} onValueChange={setPicked} allValues={ALL} aria-label="Email me about"> <Checkbox parent>Select all</Checkbox> <Checkbox value="failures">Run failures</Checkbox> <Checkbox value="quota">Quota reached</Checkbox> <Checkbox value="summary">Weekly summary</Checkbox></CheckboxGroup>In a Field
A Field gives a group its title, its description and its one error. It is written two ways today. The first example leaves htmlFor out: the group takes the Field's title as its name, its description and its error, and while the error is set every box in the group is marked invalid. The second passes htmlFor={null}, as the catalog's Field controls do: the Field is then plain markup, and the group is named by hand. Which to write is an open question below. A lone checkbox needs no Field: its text is its label.
Sent to the address you sign in with.
Sent to the address you sign in with.
<Field title="Email me about" description="Sent to the address you sign in with." error="Pick at least one."> <CheckboxGroup defaultValue={[]}> <Checkbox value="failures">Run failures</Checkbox> <Checkbox value="quota">Quota reached</Checkbox> <Checkbox value="summary">Weekly summary</Checkbox> </CheckboxGroup></Field>
<Field htmlFor={null} title="Email me about" description="Sent to the address you sign in with."> <CheckboxGroup defaultValue={["failures"]} aria-label="Email me about"> <Checkbox value="failures">Run failures</Checkbox> <Checkbox value="quota">Quota reached</Checkbox> <Checkbox value="summary">Weekly summary</Checkbox> </CheckboxGroup></Field>In the dashboard
About 40 checkboxes in 25 files, in seven kinds. The dashboard's own components/ui/checkbox.tsx renders this Checkbox, text props included. No screen uses CheckboxGroup yet: every list keeps its own set of ticked ids.
| Kind | How it is built today | File |
|---|---|---|
| One option in a form | A yes or no sent with the form. Its text is its label, with no Field around it. | components/settings/import-export/export-card.tsx |
| A list to pick from | Any number of tools, each with a description, at regular weight. | components/gateway/tool-filter-checklist.tsx |
| Select all, with “some” | A box over every permission. Its word is a span beside the box, and “some” is worked out by hand. | components/settings/permission-group-picker.tsx |
| A table’s rows | The box alone, named “Select row”. The header’s box is “some” while part of the page is selected. | ds/components/table/rows.tsx |
| With badges | An event to subscribe to: its name in mono, badges on the label’s line and a description. | components/settings/eventing/event-picker.tsx |
| With an info icon | Disabled when the gateway cannot do it. The icon says why. | components/models/model-form.tsx |
| Named by what ticking does | The text is the workspace alone, so aria-label names each box “Delete workspace” and the workspace. | components/billing/cancel-plan-dialog.tsx |
API Reference
Checkbox
Besides these, every prop of Base UI's Checkbox.Root (render, nativeButton, style) and of a <span> (title, data-testid, onClick). They land on the box, not on the label around it.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | The label, after the box. A press on it ticks the box. With none, the Checkbox is the box alone and needs an aria-label. |
size | "md" | "sm" | "md" | The control and its text together: a 14px box with 13px text, or a 12px box with 12px text. |
weight | "medium" | "regular" | "medium" | The label's weight. Regular is for long lists. |
description | ReactNode | — | A line of help under the label. It describes the box for a screen reader. |
badge | ReactNode | — | After the label, on its line: a Badge (Preview, Recommended). md beside md text, sm beside sm. |
iconTooltip | string | TooltipSettings | — | An info icon after the label: its text, or the text with the tooltip's settings (side, align, delay…). |
checked | boolean | — | Whether the box is ticked, when the page holds the state. Pair it with onCheckedChange. |
defaultChecked | boolean | false | Whether the box starts ticked, when it holds its own state. |
onCheckedChange | (checked: boolean, eventDetails) => void | — | Called when the box is ticked or cleared. A press on an unticked "some" box reports true. |
indeterminate | boolean | false | The "some" state: the bar in place of the check. A parent box sets it by itself. |
disabled | boolean | false | Half strength, no press, and out of the Tab order. |
aria-invalid | boolean | — | The Input's error edge on the box, and its error band on focus. |
aria-label | string | — | Names a box that has no text. A box with text is named by its text. To name it otherwise, also pass aria-labelledby={undefined}. |
parent | boolean | false | Makes the box stand for its whole group: a Select all. Only inside a CheckboxGroup with allValues. |
value | string | — | What the box is called in its group's list. In a form, what a ticked box submits; with none it submits on. |
name | string | — | The field's name when a form is submitted. |
uncheckedValue | string | — | What an unticked box submits. By default it submits nothing. |
form | string | — | The id of the form that owns the box, when the box sits outside it. |
required | boolean | false | Sets required on the hidden input and aria-required on the box. It draws no mark. |
readOnly | boolean | false | A press does not change the box, and it stays in the Tab order. It has no look of its own. |
id | string | — | The id of the hidden input. |
inputRef | Ref<HTMLInputElement> | — | A ref to the hidden input. |
className | string | — | Where the box sits (an alignment, a margin). Its size, corners, fill and ring are size and its state. |
CheckboxGroup
Base UI's CheckboxGroup, stacked. Besides these, every prop of a <div>.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string[] | — | The values of the boxes that are ticked, when the page holds the list. |
defaultValue | string[] | — | The values ticked at the start, when the group holds its own list. |
onValueChange | (value: string[], eventDetails) => void | — | Called with the new list when a box is ticked or cleared. |
allValues | string[] | — | Every value in the group. A parent box needs it to know what "all" is. |
disabled | boolean | false | Disables every box in the group. |
aria-label | string | — | Names the group, when no Field does. |
className | string | — | Added to the stack. The 8px between boxes is built in. |
Rules
Open questions
Over a list of choices: htmlFor null, or left out?
OpenBoth are written today, and this page shows both. Left out, a CheckboxGroup or a RadioGroup takes the Field's title, description and error itself. The catalog's Field controls pass null and name the group by hand.
Not a question the other systems have: it is about our own prop.
Do we mark the optional fields, or the required ones?
OpenThe optional ones, with a badge. Required has no mark of its own; a field can pass a Required badge through badge.
Atlassian and Primer mark the required ones with an asterisk after the label; Primer even when every field is required, and Atlassian adds a line saying what the asterisk means. Polaris's required shows an indicator.
Should the whole row tick the box?
OpenThe label is as wide as its text. In the event picker each row has a hover of its own, but a press beside the text does nothing.
Polaris has fill, which grows the label to fill what holds it, and bleed, which pads the label out into the space around it, so that space can be pressed too.
Does every box in an invalid group turn red?
OpenYes. While a Field's error is set, the Field marks every box in the group invalid, so each one takes the Input's error edge.
Primer: a single checkbox has no validation style or message of its own, and the group shows the message. Atlassian: isInvalid changes the look of an unchecked box.
Can a disabled checkbox take the focus, and where does it say why?
OpenA disabled box is at half strength and Tab skips it. design/principles.md says a disabled item stays focusable, so the two disagree. The model form disables "Use workload identity" and gives the reason in its info icon.
Atlassian: a checkbox that must stay reachable with Tab is left enabled, and an error message gives the reason it cannot be picked.
How much can the info icon hold?
OpeniconTooltip takes text of any length. The model form's "Use workload identity" puts a whole paragraph there.
Polaris: explain a checkbox with a line under it or a link to more, not with a tooltip.
Select all in Settings is built by hand
OpenCheckboxGroup with allValues and a parent box works out "some". No screen uses it: the permission picker and the export card work it out themselves, two levels deep, and write "Select all" as a span beside the box, so a press on the word does nothing.
Base UI's "Nested parent checkbox" example puts one group inside another, each with its own parent box.
Checkbox, switch, radio or select
A checkbox waits for a button. A switch acts at once
Use a checkbox for a choice that is sent later, with the form or the dialog it sits in: ticking it changes nothing until a button is pressed. Use a Switch when the change takes effect the moment it is made.
From Atlassian's toggle page (a toggle never needs a button to apply it, and a setting that does is a checkbox) and Primer's ToggleSwitch guidelines (a switch saves at once, a checkbox waits for a save). Not decided for the dashboard, which also holds switches in forms that have a Save: see the Switch page's open question.
Any number of several: checkboxes. Exactly one: radios or a Select
Use checkboxes for a list where none, one or several can be picked, and for one yes or no. Each box answers for itself: only a Select all moves other boxes.
When picking one option rules out the others, use a RadioGroup, or a Select where there is less room.
From Atlassian (radio buttons for a single choice, a dropdown for the same in less room) and Polaris (radio buttons for a single choice; each box stands alone, a select-all aside).
Labels
The text is the checkbox's own
Pass the label as children, and its help as description. The Checkbox then sets the type, the gap and the line the box centers on, and ties the words to the box for a screen reader. Never place a label beside a bare box by hand, and never draw the box from a native input or a div: if the Checkbox lacks what you need, add the prop to it and to this page.
Say what ticking does, in the positive
A label names the thing, or says what happens when the box is ticked. Sentence case, a few words, no full stop. A ticked box means yes.
From Polaris (a label is worded positively) and Atlassian (short, with no punctuation after it).
Errors
One error, in words, under the group
The red edge marks where the problem is. A Field's error says what it is, once, under the group, as under In a Field above. Color is never the only signal: the edge always comes with words.
From Primer (the group shows the message, not each box) and Atlassian (a required or invalid checkbox gets an error message).
Size and spacing
One size sets the control and its text
size sets the box, the label, the description and the info icon in one move. Never size the text with a class, or the box with className. A badge beside the label is md at md and sm at sm.
A row that holds a checkbox pads 16px around it
In a card, a row of text alone pads 12px above and below. A row that holds a control pads the full card inset, 16px, on all four sides, and a checkbox counts as a control. A Field that is a card's row does this by itself.
Accessibility
The box is Base UI's Checkbox: a <span> with the checkbox role, and a hidden native input beside it, so it works in a form and inside a label.
| Key | What it does |
|---|---|
Tab | Moves to the next box, and Shift+Tab to the one before. Each box is its own stop, in a group too. A disabled box is skipped. |
Space | Ticks or clears the box that has the focus. |
Enter | Does not tick the box. In a form, it presses the form's submit button (read in Base UI's code, not tried). |
Its name. With text, the box is named by its label (aria-labelledby) and described by its description (aria-describedby). With no text it needs an aria-label. The label wraps the box, so a press anywhere on the words ticks it.
Its state. aria-checked is true, false, or mixed for "some", so the bar is not the only signal. A disabled box carries aria-disabled. A parent box points at the boxes it controls with aria-controls.
Groups. A CheckboxGroup has the group role. Name it with aria-label, or put it in a Field: the Field's title then names the group, and its description and error describe every box in it.
The info icon. It is a stop of its own after the box, with the button role, named after the label ("Weekly summary details"). Its tooltip opens on focus.
Focus, errors and motion. Focus shows as the Input's band around the box, and is never removed. An invalid box carries aria-invalid, and its message is the Field's error, in words. The check's drawing and the box's color change stop under reduced motion.
From knowledge, not tested with a screen reader. A screen reader should say the label, "checkbox", its state (checked, not checked or mixed), then the description.
What others expose
Read on the checkbox pages of shadcn/ui, Base UI, Atlassian and GitHub Primer, and in Shopify Polaris's repository (its documentation source and its component). "Ask" means the question is open, under Rules.
| What | Who | Verdict |
|---|---|---|
| A label that fills its row, and a pressable area that reaches into the padding | Polaris (fill, bleed) | Ask: "Should the whole row tick the box?" |
| Nested groups, each with a parent box | Base UI | Ask: "Select all in Settings is built by hand". The parts exist; no screen uses them. |
| An error message on the checkbox itself | Polaris (error) | Not needed, because a Field carries the one error for a box or a group. |
| A prop for the invalid state | Atlassian (isInvalid) | Not needed, because aria-invalid is the same attribute the Input takes, and shadcn uses it too. |
| A required prop that restyles the label | Atlassian (isRequired) | Ask: nobody has decided whether required fields get a mark. Today required reaches the input and nothing is drawn. Primer marks the group as required, not the box. See the open question on required fields. |
| A prop that hides the label from the eye | Polaris (labelHidden) | Not needed, because a box with no children and an aria-label is the same thing. Primer says never to hide it. |
| An icon before the label | Primer (a leading visual) | Not needed, because the label takes any content, an icon included. |
| A label part and a description part you compose yourself | shadcn (its Field parts), Primer (its FormControl parts) | Not needed, because children and description are built in, so every box is spaced and named the same way. |
| A second color for the box | Polaris (tone) | Not needed, because a checked box has one look: the primary button's. |
"Some" as a value of checked | Polaris (checked="indeterminate") | Not needed, because indeterminate is a prop of its own, and a parent box works it out from the group. |
| A right-to-left example | shadcn | Not needed until the dashboard has a right-to-left language. |
| Props for a test id and for analytics | Atlassian (testId, analyticsContext) | Not needed, because data-testid and every other attribute pass through to the box. |