Skip to content
+

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

Props of the native component are also available.

NameTypeDefaultDescription
classNamefunc
| string
-

Class names applied to the element or a function that returns them based on the component's state.

keepMountedboolfalse

If true, the indicator stays mounted when unchecked. Useful for CSS animations.

renderelement
| func
-

A function to customize rendering of the component.


The ref is forwarded to the root element.

Theme default props

You can use CheckboxIndicator 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

Props of the native component are also available.

NameTypeDefaultDescription
autoFocusboolfalse

If true, the checkbox is focused on mount.

checkedboolundefined

If true, the component is checked.

classNamefunc
| string
-

Class names applied to the element or a function that returns them based on the component's state.

defaultCheckedboolfalse

The default checked state. Use when the component is not controlled.

disabledboolfalse

If true, the component is disabled.

idstring-

The id of the input element.

indeterminateboolfalse

If true, the checkbox will be indeterminate.

inputReffunc
| { current?: object }
-

The ref to the input element.

namestringundefined

Name of the underlying input element.

onCheckedChangefunc-

Callback fired when the checked state is changed.

Signature:function(checked: boolean, event: React.ChangeEvent) => void
  • checked The new checked state.
  • event The event source of the callback.
readOnlyboolfalse

If true, the component is read only.

renderelement
| func
-

A function to customize rendering of the component.

requiredboolfalse

If true, the input element is required.


The ref is forwarded to the root element.

Theme default props

You can use CheckboxRoot to change the default props of this component with the theme.