Skip to content
+

Checkbox

Checkboxes give users binary choices when presented with multiple options in a series.

useCheckbox API

Import

import { useCheckbox } from '@mui/base/useCheckbox';
// or
import { useCheckbox } from '@mui/base';
Learn about the difference by reading this guide on minimizing bundle size.

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.

indeterminatebooleanfalse

If true, the checkbox will be indeterminate.

inputRefReact.Ref<HTMLInputElement>-

The ref to the input element.

namestringundefined

Name of the underlying input element.

onChangeReact.ChangeEventHandler<HTMLInputElement>-

Callback fired when the state is changed.

readOnlybooleanfalse

If true, the component is read only.

requiredbooleanfalse

If true, the input element is required.

Return value

NameTypeDefaultDescription
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.