Checkbox

An easily stylable checkbox component.

API reference

Import the component and place its parts the following way:

Anatomy
import { Checkbox } from '@base-ui-components/react/checkbox';

<Checkbox.Root>
  <Checkbox.Indicator />
</Checkbox.Root>

Root

Represents the checkbox itself. Renders a <button> element and a hidden <input> beside.

PropTypeDefault
checkedbooleanundefined
classNamestring | (state) => stringundefined
defaultCheckedbooleanfalse
disabledbooleanfalse
indeterminatebooleanfalse
inputRefReact.Refundefined
namestringundefined
onCheckedChange(checked, event) => voidundefined
parentbooleanfalse
readOnlybooleanfalse
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
requiredbooleanfalse
Attribute
Description
data-checked
data-dirty
data-disabled
data-invalid
data-readonly
data-required
data-touched
data-unchecked
data-valid

Indicator

Indicates whether the checkbox is ticked. Renders a <span> element.

PropTypeDefault
classNamestring | (state) => stringundefined
keepMountedbooleanfalse
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-checked
data-dirty
data-disabled
data-ending-style
data-invalid
data-readonly
data-required
data-starting-style
data-touched
data-unchecked
data-valid