--- title: Checkbox storybookPath: forms-checkbox--default isExperimentalPackage: false ---
---
title: Checkbox
storybookPath: forms-checkbox--default
isExperimentalPackage: false
---
Checkboxes are used to toggle between checked and unchecked states — usually in
a form. If only one option from a list is allowed to be enable, consider using aRadioButton instead.
Checkboxes can be both controlled and uncontrolled. To control a checkbox
provide the checked state with a value you control, as well as an onChange
function to set the new value when the checkbox is toggled.
``jsx live
const [checked, setChecked] = React.useState(false);
return (
onChange={event => setChecked(event.target.checked)}
>
{checked &&
);
`
Checkboxes are available in two sizes: small and medium.
`jsx live`
The message is used to communicate the status of a field, such as an errortone
message. This will be announced on focus and can be combined with a tocritical
illustrate intent. The supported tones are: , positive andneutral.
`jsx live`
The Checkbox component also extends InputHTMLAttributes props and are not
listed here.
The CheckboxPrimitive component also extends InputHTMLAttributes` props and
are not listed here.
[data-attribute-map]:
https://github.com/brighte-labs/spark-web/blob/e7f6f4285b4cfd876312cc89fbdd094039aa239a/packages/utils/src/internal/buildDataAttributes.ts#L1