Backpack UI
Components
Forms
Checkbox

Checkbox & CheckboxTile

Checkbox

Checkboxes should be used to select from a group of boolean options when more than one option can be selected at a time. If using a checkbox with no label, be sure to add an aria-label="label text attribute so that users of assistive technologies can make sense of it.


React
Vanilla

_10
<FormCheckbox>label</FormCheckbox>

States

The checkbox supports the following modifiers. Note that the valid and invalid classNames are added to the input wrapper rather than the input itself.


React
Vanilla

_10
<FormCheckbox>default</FormCheckbox>
_10
<FormCheckbox checked>checked</FormCheckbox>
_10
<FormCheckbox disabled>disabled</FormCheckbox>
_10
<FormCheckbox disabled checked>disabled checked</FormCheckbox>
_10
<FormCheckbox valid={false}>invalid (pending review)</FormCheckbox>
_10
<FormCheckbox valid={false} checked>invalid checked (pending review)</FormCheckbox>

Checkbox Tiles

Tiled checkboxes offer a bigger touchable area. Note that in this case the label element has to be inserted explicitly as a child. To lay the tiles out you can use a FormGroup with the tile boolean prop modifier.

States


React
Vanilla

_10
<FormGroup tile>
_10
<FormCheckboxTile>
_10
<IconPizza />
_10
<span className="ef-boolean__label">default</span>
_10
</FormCheckboxTile>
_10
</FormGroup>

Stacked Layout

Use the FormGroup wrapper component with the tile AND stack boolean prop modifiers to make the most of the stacked layout.


React
Vanilla

_10
<FormGroup tile stack>
_10
<FormCheckboxTile>
_10
<IconPizza />
_10
<span className="ef-boolean__label">default</span>
_10
</FormCheckboxTile>
_10
</FormGroup>