Checkbox
A checkbox marks an option as chosen. Use it when someone can pick several options, or agree to one statement, and then confirms with a button.
What it is
Two of the four documents are in, so All documents shows the mixed state.
When to use it
Use a checkbox when someone picks any number of options from a list, or agrees to one statement, and the choice counts once they press the form's button.
If the choice should apply the moment it is made, use a switch. If only one option may be chosen, use radio buttons, or a select for a long list. Past seven options, split the group under two labels or use a combobox that takes several choices.
Anatomy
The box sits on the first line of its label, and a long label wraps under itself. The whole row is the target: a click on the words checks the box too.
- Box
- 16 px
- Box in a dense table row
- 14 px
- Box in a checklist on a phone
- 22 px
- Corner radius
- 4 px, 6 px on the 22 px box
- --radius-sm
- Fill
- white in light, control gray in dark
- Edge
- 1 px, gray in light, faint white in dark
- Label
- 14 px on a 20 px line
- --text
- Gap to the label
- 8 px
- --space-2
- Row height
- at least 24 px, 44 px on touch
- Indent under a parent
- 24 px
- --space-6
States
A checkbox does not change under the pointer. A disabled one keeps its words readable, and the hint under the group says why it cannot be changed.
- Rest
- Focus
- Checked
- Mixed
- Disabled
- Disabled checked
- Error
- Rest
- Focus
- Checked
- Mixed
- Disabled
- Disabled checked
- Error
- Checked and mixed
- brand blue fill, no edge
- --brand-blue
- Tick and bar
- white
- --on-brand
- Focus ring
- 2 px, 2 px outside the box
- --focus-ring
- Disabled
- the box at half strength, the label muted
- --text-muted
- Error edge
- 1 px
- --error
Groups and the mixed state
Give a group a label that says what the options share, and put any requirement in it: Choose at least one document.
A parent checks or clears all of its options. While some are checked it shows the mixed state, and a click on it checks the rest. Indent the options under their parent.
- Mixed
- After one click
- After a second click
Keyboard and screen readers
Tab moves to each checkbox, and Space checks or clears it. Enter submits the form.
A screen reader hears the label and the state, mixed for a parent, and the group label once as focus enters the group. A checkbox with no words of its own, such as the one that selects a candidate in a board, takes a name that includes the row: Select Bishal Tamang.
Writing the label
Write labels in sentence case, without a full stop, and state the positive so that checked means yes. Keep options parallel, all nouns or all verbs, and move a word they share into the group label. Order them from the simplest to the most complex, or from the safest to the riskiest when a choice can lose data.
Permitted
A label that states the positive: Notify the candidate.
Not permitted
A label that makes checked mean no: Do not notify the candidate.
Whoever fills in the form has to undo a negative before they can answer.