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
AttributeType
data-checkedEmpty attribute
data-dirtyEmpty attribute
data-disabledEmpty attribute
data-invalidEmpty attribute
data-readonlyEmpty attribute
data-requiredEmpty attribute
data-touchedEmpty attribute
data-uncheckedEmpty attribute
data-validEmpty attribute

Indicator

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

PropTypeDefault
classNamestring | (state) => stringundefined
keepMountedbooleanfalse
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
AttributeType
data-checkedEmpty attribute
data-dirtyEmpty attribute
data-disabledEmpty attribute
data-ending-styleEmpty attribute
data-invalidEmpty attribute
data-readonlyEmpty attribute
data-requiredEmpty attribute
data-starting-styleEmpty attribute
data-touchedEmpty attribute
data-uncheckedEmpty attribute
data-validEmpty attribute