Skip to Content
ComponentsCheckbox

Checkbox

A styled checkbox built on Base UI’s Checkbox primitive. Supports checked, unchecked, and indeterminate states with a compound component pattern.

Import

import { Checkbox } from "chunks-ui";

Basic Usage

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

With Label

Use the Field component to associate a label:

<Field.Root> <div className="flex items-center gap-2"> <Checkbox.Root> <Checkbox.Indicator /> </Checkbox.Root> <Field.Label>Accept terms and conditions</Field.Label> </div> </Field.Root>

Controlled

function ControlledCheckbox() { const [checked, setChecked] = useState(false); return ( <Checkbox.Root checked={checked} onCheckedChange={setChecked}> <Checkbox.Indicator /> </Checkbox.Root> ); }

Indeterminate State

The indeterminate state is used for “select all” patterns where some items are checked:

<Checkbox.Root checked="indeterminate"> <Checkbox.Indicator /> </Checkbox.Root>

Disabled

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

Compound Parts

PartDescription
Checkbox.RootThe checkbox control. Handles checked state and keyboard interaction.
Checkbox.IndicatorRenders the check/indeterminate icon inside the root.

Checkbox.Root Props

PropTypeDefaultDescription
checkedboolean | "indeterminate"Controlled checked state
defaultCheckedbooleanfalseInitial checked state (uncontrolled)
onCheckedChange(checked: boolean) => voidCalled when checked state changes
disabledbooleanfalseDisable the checkbox
classNamestringAdditional CSS classes

Checkbox.Indicator Props

PropTypeDefaultDescription
classNamestringAdditional CSS classes
Last updated on