Live demo
Demo source
Use checkboxes to let people select any number of options from a group, such as the notifications they want to receive. For a single setting that applies immediately, use a toggle; for exactly one choice from a group, use radio buttons.
Anatomy
A checkbox with three callouts: 1 marks the empty checkbox, 2 the label Label to its right, and 3 the description below the label.
- Checkbox shows whether the option is selected. Clicking it or its label, or pressing Space, toggles it.
- Label names the option; set it with
label.hideLabelhides it visually but keeps it for screen readers. - Description (optional) adds context below the label.
States
A checkbox is unchecked, checked or indeterminate. Indeterminate shows that
only some options in a group are selected, usually on a "select all"
checkbox; your application sets it, and selecting the checkbox clears it.
Hover and focus styles are built in. disabled prevents interaction;
readonly keeps the checkbox focusable but prevents changes.
For an invalid choice, set error with an errorDescription that says how to
fix it: the checkbox turns red and the message appears below it.
Label placement
The label sits after the checkbox by default. labelPlacement="before"
places it first; keep the description beside the same label and use one
placement consistently within a group.
Themes
The design includes Spark and Ocean appearances. Use the page's theme and mode controls to compare the live examples; retain the same labels, states and validation messages in each theme.
Guidelines
- Group related checkboxes under a clear heading, such as a
fieldsetwith alegend. - Offer a "select all" checkbox when people often want every option.
- Do not preselect options without a clear reason, such as a default preference.
- Do not mix checkboxes and radio buttons in one group.