Checkbox
Checkbox gives users a binary choice between multiple options in a series.
CheckboxIndicator API
Import
import * as Checkbox from '@base_ui/react/Checkbox';
const CheckboxIndicator = Checkbox.Indicator;
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
className | func | string | - | Class names applied to the element or a function that returns them based on the component's state. |
keepMounted | bool | false | If |
render | element | func | - | A function to customize rendering of the component. |
ref
is forwarded to the root element.Theme default props
You can useCheckboxIndicator
to change the default props of this component with the theme.CheckboxRoot API
Import
import * as Checkbox from '@base_ui/react/Checkbox';
const CheckboxRoot = Checkbox.Root;
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
autoFocus | bool | false | If |
checked | bool | undefined | If |
className | func | string | - | Class names applied to the element or a function that returns them based on the component's state. |
defaultChecked | bool | false | The default checked state. Use when the component is not controlled. |
disabled | bool | false | If |
id | string | - | The id of the input element. |
indeterminate | bool | false | If |
inputRef | func | { current?: object } | - | The ref to the input element. |
name | string | undefined | Name of the underlying input element. |
onCheckedChange | func | - | Callback fired when the checked state is changed. Signature: function(checked: boolean, event: React.ChangeEvent
|
readOnly | bool | false | If |
render | element | func | - | A function to customize rendering of the component. |
required | bool | false | If |
ref
is forwarded to the root element.Theme default props
You can useCheckboxRoot
to change the default props of this component with the theme.