A checkbox is an input control that allows users to select zero, one, or more options from a number of choices.
Preview
Usage
Checkboxes are an easily understandable way to indicate that users can select one or more answers to a question or items from a list. They visibly show users what’s been selected and makes it easy for them to “uncheck” an option, which can be difficult with other selection methods on a form (such as radio buttons or select menus).
Do
- Selecting any number of choices from a set list.
- Binary selections that convey opposite states, such as check=“on” and unchecked=“off”, paired with a label that conveys the choice.
- When users need to see all the available options at a glance.
Best Practices
- Users should be able to tap on or click on either the text
labelor the checkbox element itself to toggle an option, aiding accessibility. - Options that are listed vertically are easier to read than those listed horizontally. Horizontal listings can make it difficult to tell which label pertains to which checkbox.
- Negative language in labels can be counterintuitive. For example, use "I want to receive a promotional email" instead of "I don’t want to receive promotional email".
- Make sure that the label makes both states — checked and unchecked — clear to the user. If that’s not possible, consider using a Radio button with two individual options instead. Then both states can have their own clearly marked label.
- Make sure selections are adequately spaced for touch screens.
- Multiple checkbox options should be organized in a meaningful way, like alphabetical or most-frequent to least-frequent. This helps users easily find the option they’re looking for.
indeterminatecheckboxes convey a "mixed" state that neither qualifies as checked or unchecked. An example use case is when a checkbox acts as a "parent" of a collection of child checkboxes:checked: all children are checked.unchecked: all children are not checked.indeterminate: children are a mix of checked and unchecked.
Variants and Examples
Base Styles
Indeterminate
Stacked Group
With Description Text
With Validation States
Vue API
Slots
Props
Events
Classes
Accessibility
The best accessibility is semantic HTML. Most screen readers understand how to parse inputs if they’re correctly formatted. When it comes to checkboxes, there are a few things to keep in mind:
- All inputs should have an
idattribute. - Associate checkbox labels with their inputs using the
forattribute. This correlates with the checkbox'sid. - If you have a group of related checkboxes, use a
fieldsetto group them and alegendto title the group. For further information, please visit Gov.UK’s article, "Using the fieldset and legend elements". - Input with description text should have
aria-describedbywith theidof the description text. - If the input is a required field, use the
aria-requiredproperty and use the validation message for input errors. - Input with validation errors should have
aria-describedbywith theidof the validation message.