Skip to content
+

Checkbox

Checkbox gives users a binary choice between multiple options in a series.

useCheckboxRoot API

Import

import { useCheckboxRoot } from '@base_ui/react/Checkbox';

Parameters

NameTypeDefaultDescription
autoFocusbooleanfalse

If true, the checkbox is focused on mount.

checkedbooleanundefined

If true, the component is checked.

defaultCheckedbooleanfalse

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

disabledbooleanfalse

If true, the component is disabled.

idstring-

The id of the input element.

indeterminatebooleanfalse

If true, the checkbox will be indeterminate.

inputRefReact.Ref<HTMLInputElement>-

The ref to the input element.

namestringundefined

Name of the underlying input element.

onCheckedChange(checked: boolean, event: React.ChangeEvent<HTMLInputElement>) => void-

Callback fired when the checked state is changed.

readOnlybooleanfalse

If true, the component is read only.

requiredbooleanfalse

If true, the input element is required.

Return value

NameTypeDescription
checkedboolean

If true, the checkbox is checked.

getButtonProps(externalProps?: React.ComponentPropsWithRef<'button'>) => React.ComponentPropsWithRef<'button'>

Resolver for the button element's props.

getInputProps(externalProps?: React.ComponentPropsWithRef<'input'>) => React.ComponentPropsWithRef<'input'>

Resolver for the input element's props.