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.
Don’t
If a user can only select one option from a list; consider using Radio or Select.
If there are too many options to reasonably display in its context.
Users should be able to tap on or click on either the text label or 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.
indeterminate checkboxes 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.
<dt-checkbox-grouplegend="Call Blocking & Spam Protection":selectedValues="[]"><dt-checkboxname="option1"value="Value"label="Anonymous callers"/><dt-checkboxname="option2"value="Value"label="Block callers not already in contacts list"/><dt-checkboxname="option3"value="Value"label="Block callers with a high spam score"/></dt-checkbox-group>
<dt-checkbox-grouplegend="Call Blocking & Spam Protection":selectedValues="[]"><dt-checkboxname="option1"value="Value"label="Anonymous callers"description="Select how phone numbers you dont know should be handled."/><dt-checkboxname="option2"value="Value"label="Block callers not already in contacts list"description="You get enough calls. Free up some of your time."/><dt-checkboxname="option3"value="Value"label="Block callers with a high spam score"description="We will only let the legitimate callers through to bother you."/></dt-checkbox-group>
<dt-checkbox-grouplegend="Call Blocking & Spam Protection":selectedValues="[]"><dt-checkboxname="option1"value="Value"label="Anonymous callers"validation-state="warning":messages="[{ message: `Select how phone numbers you dont know should be handled.`, type: `warning` }]"/><dt-checkboxname="option2"value="Value"label="Block callers not already in contacts list"validation-state="critical":messages="[{ message: `You get enough calls. Free up some of your time.`, type: `critical` }]"/><dt-checkboxname="option3"value="Value"label="Block callers with a high spam score"validation-state="positive":messages="[{ message: `We will only let the legitimate callers through to bother you.`, type: `positive` }]"/></dt-checkbox-group>
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 id attribute.
Associate checkbox labels with their inputs using the for attribute. This correlates with the checkbox's id.
If you have a group of related checkboxes, use a fieldset to group them and a legend to 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-describedby with the id of the description text.
If the input is a required field, use the aria-required property and use the validation message for input errors.
Input with validation errors should have aria-describedby with the id of the validation message.