Blueprint

Checkbox

Checkboxes are an easily understandable way to indicate that users can select one or more options from a group, or that a user can make a binary (yes/no) choice. Checkboxes can also be used in the context of bulk actions, where a user might select 2 or more items from a list and then perform an action on all of the items.

Design guidance

When and how to use this

Use checkboxes in cases where users can select multiple options from a group, or when the user needs to make a binary (yes/no) choice, such as accepting or not accepting terms of service in a signup form. You should also use a checkbox in the bulk action use case noted above. For more on bulk action patterns, see the Table documentation.

For these cases, a Checkbox is the best choice—avoid using a Switch for the purpose of selecting options or binary choices outside of global on/off choices in native mobile apps.

When to consider something else

If a user should only select one of a number of options, use a Radio or Select instead of a Checkbox.

For use cases in mobile native apps where the user has a binary choice that globally affects the app (for example, a global setting) that does not require an explicit save, use a Switch.


Figma

For most form-driven use cases, drag in a Checkbox Field Group from the Compositions section in the Form Controls v2 library in the Assets pane in your Figma file. We provide default and error states as well as a required attribute for the field. A Checkbox Field component is nested within, which then nests an atomic Checkbox component inside. To set the checked attribute and state on a button within the Checkbox Field Group, select the nested Checkbox and use Figma’s component property pane to make changes.

Drag in a single Checkbox Field for yes/no use cases like accepting terms. For bulk action cases, you just need a Checkbox, which has an Indeterminate attribute to indicate that some (but ont all) items in the associated list are selected.

You can also drag in a Checkbox Tile Field to match the React TileRadio shown below.

React

Checkbox composes Chakra’s Checkbox. We offer size variants that align with those in TextInput. We also offer a CheckboxGroup that wraps a set of Checkbox components, controls their values, and distributes some common props such as size and isDisabled, and a TileCheckbox that offers a checkbox wrapped in a tile-like element and offers more text styling options.

live

<Stack direction="column" spacing="400">
<Checkbox>I'm idle</Checkbox>
<Checkbox isChecked>I'm checked</Checkbox>
<Checkbox isChecked isIndeterminate>
I'm indeterminate
</Checkbox>
<Checkbox isInvalid>I'm invalid</Checkbox>
<Checkbox isDisabled>I'm disabled</Checkbox>
</Stack>


PropDescription
sizeSets the size of the Checkbox and its associated label.
isCheckedif true, the Checkbox will be checked. You'll need to pass onChange to update its value (since it is now controlled).
isDisabledif true, the Checkbox will be disabled.
isInvalidif true, the Checkbox will be invalid and its aria-invalid will be set to true.
isIndeterminateif true, the Checkbox will be show the indeterminate state “bar” rather than a check. This only affects the icon inside the checkbox, and does not modify the isChecked property..

Checkbox Group

Use a CheckboxGroup for cases where you need a group of associated checkboxes. It uses the same props as the basic Checkbox and applies these across each checkbox in the group. In addition, you can use the defaultValue prop on this component to set a checkbox in the group as checked by default.

live

<Stack direction="column" spacing="400">
<CheckboxGroup defaultValue="1">
<Checkbox value="1">Checkbox 1</Checkbox>
<Checkbox value="2">Checkbox 2</Checkbox>
<Checkbox value="3">Checkbox 3</Checkbox>
</CheckboxGroup>
</Stack>

Size

Checkbox is available in three sizes and defaults to medium. The size set on CheckboxGroup will be distributed to child Checkbox components.

live

<Stack spacing="400">
<CheckboxGroup size="small" defaultValue="1">
<HStack justifyContent="space-around">
<Checkbox value="1">Small 1</Checkbox>
<Checkbox value="2">Small 2</Checkbox>
<Checkbox value="3">Small 3</Checkbox>
</HStack>
</CheckboxGroup>
<Divider />
<CheckboxGroup size="medium" defaultValue="1">
<HStack justifyContent="space-around">
<Checkbox value="1">Medium 1</Checkbox>
<Checkbox value="2">Medium 2</Checkbox>
<Checkbox value="3">Medium 3</Checkbox>
</HStack>
</CheckboxGroup>
<Divider />
<CheckboxGroup size="large" defaultValue="1">
<HStack justifyContent="space-around">
<Checkbox value="1">Large 1</Checkbox>
<Checkbox value="2">Large 2</Checkbox>
<Checkbox value="3">Large 3</Checkbox>
</HStack>
</CheckboxGroup>
</Stack>


Tile Checkbox

TileCheckbox allows for both a label as in the standard Checkbox component, but also offers a description prop to set secondary text in the tile. It also offers an isSubtle prop to remove the border of the element in its default state. You can wrap a set of TileCheckbox components in a CheckboxGroup just like the standard Checkbox.

live

<Stack direction="column" spacing="400">
<TileCheckbox description="Description goes here">I'm idle</TileCheckbox>
<TileCheckbox description="Description goes here" isChecked>
I'm checked
</TileCheckbox>
<TileCheckbox description="Description goes here" isInvalid>
I'm invalid
</TileCheckbox>
<TileCheckbox description="Description goes here" isDisabled>
I'm disabled
</TileCheckbox>
</Stack>


Bootstrap

Bootstrap provides styles for input type=”checkbox” and accompanying label elements, using the .form-check-input and .form-check-label classes wrapped in a div with the class .form-check. Wrap groups of these in a fieldset and use the .form-label class on its legend to achieve the same effect as the React CheckboxGroup.

live

<fieldset>
<legend class="form-label mb-6">Checkbox field</legend>
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
value=""
id="defaultCheck1"
/>
<label class="form-check-label" for="defaultCheck1"> First checkbox </label>
</div>
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
value=""
id="defaultCheck2"
/>
<label class="form-check-label" for="defaultCheck2">
Second checkbox
</label>
</div>
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
value=""
id="defaultCheck2"
/>
<label class="form-check-label" for="defaultCheck2">
Third checkbox is third
</label>
</div>
</fieldset>

ClassDescription
.form-check-input and .form-check-labelInvokes Bootstrap theme styles for checkboxes and accompanying labels.
.form-checkRequired class on a wrapper div around the checkbox and label elements.
.form-labelInvokes Bootstrap theme styles for the legend on a fieldset that wraps a .form-check div and its children, as shown above.