Skip to content

Checkbox

Edit on GitHub
@volvo-cars/css v2.3.0@volvo-cars/react-forms v2.0.0

Checkboxes permit multiple selections from a set of options. They are suitable for choosing an option or as an alternative to a toggle for a preferred choice. When used in a list, it should always be possible to select all, none, or some of the options.

The checkbox component changes content and visual treatment depending on which state it is in.

Checkbox anatomy

  1. Label
  2. Container
  3. Message (Optional)
  4. Icon
  5. Container filled

Use checkboxes for multiple selection from a set of options.

  • Use checkbox to select one or more options from a list
  • Use checkbox to present a list containing sub-selections
  • Use checkbox to turn an item on or off in a desktop environment
  • Do not use checkboxes when only one item can be selected from a list. Use radio buttons instead.

The unselected state for a checkbox with label refers to a checkbox that has not been clicked or checked by the user, and it is accompanied by a text label that describes what the checkbox is for.

Unselected checkbox variant

The selected state for a checkbox with label refers to the status of a checkbox when it has been clicked or chosen by the user. This selection is often indicated by a checkmark or a change in color.

Selected checkbox variant

The indeterminate variant is a special state of a checkbox where it shows a partially-selected or mixed state, typically used when a parent checkbox represents a group of sub-checkboxes where some, but not all, of the child items are selected.

Indeterminate checkbox variant

Checkboxes can be either selected or unselected. They have five states: enabled, disabled, hover, focused, and pressed.

The default state in checkboxes refers to how the checkbox appears when it has not been interacted with. In this state, it typically consists of a checkbox container and a text label.

Unselected checkbox in default state

Shows an unselected checkbox with a label in its default state.

Selected checkbox in default state

Shows a selected checkbox with a label in its default state.

A hover state for a checkbox is displayed when the user moves their cursor over the checkbox, before they actually click on it. It’s usually used to indicate that the checkbox is interactive.

Unselected checkbox in hover state

Shows an unselected checkbox with label in hover state.

Selected checkbox in hover state

Shows a selected checkbox with label in hover state.

The pressed state for a checkbox refers to the visual representation when a user clicks or touches the checkbox but hasn’t yet released it. This state often indicates that the checkbox is active and ready to change status once the click or touch is released.

Unselected checkbox in pressed state

Shows an unselected checkbox with label in pressed state.

Selected checkbox in pressed state

Shows a selected checkbox with label in pressed state.

The disabled state of a checkbox refers to a user interface element that users cannot interact with, typically because certain conditions haven’t been fulfilled.

Unselected checkbox in disabled state

Shows an unselected checkbox with label in disabled state.

Selected checkbox in disabled state

Shows a selected checkbox with label in disabled state.

The error state for a checkbox occurs when it is marked as incorrect. This typically happens when it hasn’t been appropriately filled out or selected as required.

Unselected checkbox in error state

Shows an unselected checkbox with label in error state.

Selected checkbox in error state

Shows a selected checkbox with label in disabled state.

Checkboxes in light mode

Displaying checkboxes in light mode

Checkboxes in dark mode

Displaying checkboxes in dark mode

Our checkboxes are normally placed in a stacked format, always with a spacing of 16px distance between each other.

Checkbox vertical spacing

Checkboxes use a 16px spacer when grouped.

Checkbox horizontal spacing

Checkboxes use a 16px spacer when arranged horizontally

Checkbox message spacing

Checkboxes and their messages use 4px spacing between them.

Checkboxes can be arranged either horizontally or vertically.

Checkboxes arranged vertically

Shows checkboxes with labels arranged vertically.

Checkboxes arranged horizontally

Displays checkboxes with labels aligned horizontally.

Hint messages are short messages used to add more context or purpose.

Checkbox with hint message

Shows a checkbox with label and hint message.

The Error message is shown when an error occurs. Error messages are shown below the checkbox label together with a change of border color.

Checkbox with error message

Displaying a checkbox with label and error message.

Hint messages are used alongside error messages to provide additional guidance on how to resolve the issue.

Checkbox with hint and error message

Shows a checkbox with label, error message, and hint message.

Label: Max 40 char

Form message: Max 150 char

add example

The checkbox component uses the default keyboard focus wrapped around the checkbox container.

Checkbox with keyboard focus

Displaying checkbox with label on keyboard focus.

Use checkboxes for multiple selection

Use checkboxes for multiple selection from a set of options.

Use radio buttons for single selection

Use Radio buttons instead of checkboxes when only one item can be selected from a list.

Don't use checkboxes for single selection

Don’t use checkboxes when only one item can be selected from a list.