Demos

A checkbox with its label.

Usage

Use a checkbox to pick any number of options from a list, or for one choice that applies when a form is submitted. For a setting that takes effect right away, use a Switch. To pick exactly one option, use a Radio Group.

Import it from @workspace/ui/components/checkbox.

Notes

  • Wrap the checkbox in a label so the text toggles it too.
  • The hit area is larger than the box, so it is easy to tap.
  • Write the label as a statement the reader agrees with, such as "I have fasted for 8 hours".
  • Space toggles the checkbox when it has focus.

Examples

With description

A title and a line of help text, with the box aligned to the first line.

Disabled

Disabled checkboxes, unchecked and checked.

Group

A parent checkbox that selects all children. It shows a dash with indeterminate when only some are selected.

Props

These are the props you set most often. Unlisted props pass through to the underlying element.

Checkbox

PropTypeDefaultDescription
defaultCheckedbooleanfalseChecked on first render.
checkedboolean—State when controlled.
onCheckedChange(checked) => void—Called when the state changes.
indeterminatebooleanfalseShows the mixed state, for a parent of a partly selected list.
disabledbooleanfalseBlocks input and dims the checkbox.
namestring—Field name for form submission.
valuestring—Value submitted when checked.