Checkbox
Checkbox is a form control for single and multiple selections.
Page navigation navigation
React
readyNot reviewed for a11y
Rails
readyNot reviewed for a11y
Figma
It's unlikely that you'll be rendering a single Checkbox. See the CheckboxGroup component for rendering a set of Checkboxes.
Best practices
- An individual Checkbox should not have its own validation message or style. Instead, show a validation message on the CheckboxGroup. For more information, see the Validation Message section in the Forms documentation.
- While there are certain use cases where an individual checkbox may be required, the most common use case is to require a selection from a CheckboxGroup. In this case, an individual checkbox button should not be marked as required, but the checkbox group should be marked as required instead. For more information, see the Required field indicator in the Forms documentation.
React examples
Default
With a caption
This is a caption
With a leading visual
In a group of Checkboxes
This example uses the CheckboxGroup component to render a set of Checkboxes.
Indeterminate
More code examples
See the Checkbox Storybook stories
Props
Checkbox
Name | Required | Description |
---|---|---|
checked | boolean Modifies true/false value of the native checkbox | |
defaultChecked | boolean Checks the input by default in uncontrolled mode | |
disabled | boolean Modifies the native disabled state of the native checkbox | |
indeterminate | boolean Applies an [ indeterminate state ](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#attr-indeterminate) to the checkbox | |
onChange | (event: React.ChangeEvent) => void A callback function that is triggered when the checked state has been changed | |
validationStatus | 'error' | 'success' Only used to inform ARIA attributes.<br /> Individual checkboxes do not have validation styles. | |
value | string A unique value that is never shown to the user.<br /> Used during form submission and to identify which checkbox inputs are selected. | |
ref | React.RefObject<HTMLInputElement> | |
as | React.ElementType | |
sx | SystemStyleObject |