Checkboxes
A checkbox allows a user to select one or more items from a set of options. It may also be used to agree to a statement.
Default Checkbox Example
When to Use
- Use when the user may select one or more items from a predetermined list of options.
- Use when the options are relatively simple/short in length.
When Not to Use
- Do not use checkboxes for on/off selections that occur immediately. Consider using a Switch instead.
Examples
- Default Example (shown above)
- Default with Error Example
- Indeterminate Checkbox Example
Examples
Default with Error
Indeterminate Checkbox
When to Use
- Use when providing a “Check All” option with a sublist of checkbox options. The indeterminate state should be displayed when the sublist contains both checked and unchecked items.
Developer Notes
Order Matters
The <input>
element must be the first item inside of the checkbox container. Otherwise the disabled
state will not work properly.
Default
Default with Error
Indeterminate Checkbox
The indeterminate state of Checkboxes can only be set using Javascript. This is done by setting the indeterminate property to true as shown in the example below.
Note: Keep in mind that if submitting a form with an indeterminate checkbox, it will be as if the checkbox were unchecked, and no data would be submitted for that specific checkbox.