Checkboxes allow users to select one or more items from a group of options.
The Checkbox, Radio, and Toggle components are all form controls that allow a user to select options. However, it's important to understand the difference as they are not interchangeable:
Standalone Checkboxes are suitable for choices such as confirming an action, agreeing to terms, or enabling a single feature. Multiple options should be presented within a CheckboxGroup to take advantage of parent Checkbox controls and a shared label.
When using a select all parent Checkbox, use Indeterminate to make it clear when not all options are selected.
Unchecked and checked Checkboxes show default styles with no user interaction.
On mouse hover, the border color updates for unchecked Checkboxes and the background color darkens for checked Checkboxes.
On keyboard focus, the Checkbox receives the standard 2px focus ring.
Disabled Checkboxes cannot be interacted with. The background color updates to indicate the Checkbox is unavailable.
The Checkbox adopts the critical color treatment to indicate there's an error. An error message displays below the Checkbox when set.
Indeterminate is a state represented by a horizontal dash instead of a checkmark and communicates partial Checkbox group selection. Within a group of Checkboxes, a parent Checkbox can control the state of its children. When only some children are selected, the parent checkbox adopts the indeterminate role.
The indeterminate state is unrelated to the checked state; a Checkbox may still be either checked or unchecked while indeterminate. This state is purely for visual communication.
A dash icon replaces the checkmark to indicate partial selection within a controlled group.
Truncation can be enabled for longer labels that would otherwise extend past the parent container. Truncation prevents text wrapping and will display an ellipsis to cut the label short when applicable.
When enabled, truncation clips the label to prevent wrapping.
Assistive text displays below the Checkbox and gives the user information about the form field they're interacting with. Assistive text comes in different forms including descriptions and error text.
Descriptions provide extra context to the Checkbox option when the label itself will not suffice. Short phrases are preferred and end punctuation is unnecessary.
Error messages communicate issues with the Checkbox that the user must resolve before submission. Frame validation errors as direct instructions, not accusations. Be sure to provide guidance on how to fix the error. Keep messages direct and concise. Never use "Please".
Write labels that clearly describe what option the Checkbox controls or represents. Labels should be self-explanatory without relying on surrounding context.
For option Checkboxes, phrase labels as the setting or feature being enabled:
For confirmation or agreement checkboxes, use short first-person statements: