Skip to main content

Checkboxes

Usage

Definition

Checkboxes allow a user to select one or more items from a list of options. For unusually long lists which must be contained inside a scrollable area, combine checkboxes with a text search to help users more easily find the desired options.

Avoid using single checkboxes (exception: “Remember username” function in sign in forms).

Common Characteristics

All checkboxes allow the user to tap the checkbox or associated label. The label is vertically centered with the checkbox even when the text wraps. Checkboxes should normally be active and unchecked by default.

Checkboxes buttons have these states: active unchecked, or hover/tap, or checked, or indeterminate; and disabled unchecked, or checked, or

Scenarios

Horizontal

When necessary to use a horizontal layout, ensure there is at least 32px space between each checkbox/label element.

checkbox horizontal

Nesting

In nested layouts, selecting a parent checkbox implies the selection of all its children, even though the child text boxes are not displayed as selected. Selecting any one child checkbox implies the selection of its parent, even though the parent is not displayed as selected.

check filters

With Filter Counts

When using checkboxes as filters with counts, right align the counts.

32
12
55
43

check nested

States

Checkboxes buttons have these states: active unchecked, or hover/tap, or checked, or indeterminate; and disabled unchecked, or checked, or indeterminate.








Code

Default Uncontrolled Checkbox

The Checkbox component is now uncontrolled. It will take a checked prop, but is rendered as defaultChecked.

Live Editor
Result
Loading...

Default Controlled Checkbox

Live Editor
Result
Loading...

Disabled Checkbox

Live Editor
Result
Loading...

Indeterminate Checkbox

Live Editor
Result
Loading...

Checkboxes Props

NameTypeDefaultDescription
checkedboolfalseSets the checked state of the checkbox
classNamestringnullSets a custom class name on the checkbox
disabledboolfalseDisables checkbox and applies disabled styles
labelstringnullSets the label text shown next to the checkbox
namestringnullSets the name attribute of the checkbox to make it unique
requiredboolfalseSets whether or not the checkbox is required
valueanynullSets the value of checkbox when selected
onChangefunctionnullSets the function to be called when a checkbox is checked or unchecked