Checkbox
Input component for selecting or deselecting an option.
Examples
Controlled state
To use Checkbox in controlled mode, use the isChecked
and onCheckedChanged
props with your local state.
Uncontrolled state
To use Checkbox in uncontrolled mode with an initial value, use the isDefaultChecked
prop.
Helper text
Use the helperText
prop to provide additional context for the Checkbox.
Invalid state
Use the isInvalid
prop along with errorMessage
to indicate an invalid state. The error message will be visible only when isInvalid
is set to true.
Will be displayed below the input field, replacing any helperText
.
With link
The label
prop accepts also accepts React components for the times when an inline link is needed.
Use sparingly
Can cause usability issues, use only when necessary.
API Reference
Prop | Default | Description |
---|---|---|
label | - | string | ReactElement<unknown, string | JSXElementConstructor<any>> The label for the checkbox. Accepts a string, or a React component for rendering links within the label. |
helperText? | - | string Text that provides additional guidance to the user |
isDefaultChecked? | - | boolean The checked state of the checkbox when it is initially rendered. Use when you do not need to control its checked state. |
isChecked? | - | boolean The controlled checked state of the checkbox. Must be used in conjunction with |
onCheckedChange? | - | ((checked: boolean) => void) Event handler called when the checked state of the checkbox changes. |
isInvalid? | false | boolean If |
isDisabled? | false | boolean If |
isRequired? | false | boolean If |