The checkbox component is used to provide multiple options the user can select, including all or none. They work independently from each other, therefore checking an additional box does not affect the other selections. Checkboxes are not mutually exclusive.
Labels for checkboxes are placed to the right of the checkbox. If there's a checkbox group, the options can be vertically or horizontally stacked, depending on the use case and UI needs. Vertically stacking the checkboxes is preferable for better readability.
Checkboxes in JSTOR are often used when faceting results so users can narrow their focus, or on forms. They can be placed within pages or modals.
- Use checkboxes when users need to choose "yes" or "no" per option
- Checkboxes should work independently from each other, unless there are checkboxes to control groups
- Checkboxes should always include a label
- Use checkboxes when choices are not mutually exclusive
- The list of choices should be in a logical order
- Don't use checkboxes when there are no choices or a choice is non-binary
- Don't use where only one choice in a group is allowed. Consider using the radio button component instead
- Don't make checkboxes affect other checkboxes unless for bulk selection actions
- For a grouping of checkboxes, you can include a heading to provide even greater clarity. This is especially helpful if there multiple groups on a page, form or experience.
- Use Sentence case for group labels.
- Labels are descriptive and succinct. They should provide further clarity for the user.
- Labels should not end in punctuation.
- Use Sentence case for labels.
- Avoid using negative language as it can be counterintuitive. For example, "I agree to the terms" instead of "I don't agree to the terms."
- Long labels may wrap to a second line, but consider rewording the label if it gets too long.
- Labels should not be truncated.
In cases where the background containing the checkbox will be a dark color or, in cases where the theme of the page/component would be dark, use the isOnBackground variant checkbox.
Indicates that the checkbox is interactable.
Indicates that the checkbox should not be interactable.
Indicates that the user must specify a value for the input before the form can be submitted.
Indicates that an error occurred within the checkbox.
Indicates that the checkbox is selected and will submit a checked value of true.
Indicates that the checkbox is not selected and will submit an unchecked value of false.
A state that serves a visual purpose while masking the actual value of the checkbox.
4.1.2 Name, Role, Value A
Checkboxes help users to understand the relationship between selections in a form element or filter. A checkbox grouping also will typically allow users to select more than one item in the grouping.
- The checkbox has the role "checkbox".
- When the checkbox is selected, the ARIA state is set to
aria-checked="true"and when it is deselectedaria-checked="false". - Provide a
fieldsetthat surrounds the entire grouping of checkboxes. Also, provide alegend, which is a description for the grouping.Here's an example. - Some assistive technology reads the legend text for each fieldset, so it should be brief and descriptive. This helps someone using assistive technology to understand the question they are answering with the group of checkboxes
- Reads: "item name, state (checked or unchecked), checkbox, fieldset name, group"
- The Space key can be used to select and deselect each checkbox when it has focus.
- Users can navigate between checkbox inputs by pressing Tab or Shift-Tab.
- Checkboxes identified as
disabledattribute are ignored in the tab order.