UIIcons

Checkbox

A control that allows the user to toggle between checked and not checked.

By clicking this checkbox, you agree to the terms.

Checkbox

Installation

pnpm dlx stera-ui@latest add checkbox

Composition

Use the following composition to pair a Checkbox with a label:

Field
├── Checkbox
└── FieldLabel

To add a description, wrap the label and helper text in FieldContent:

Field
├── Checkbox
└── FieldContent
    ├── FieldLabel (or FieldTitle)
    └── FieldDescription

To group related checkboxes, nest Fields inside a FieldGroup and FieldSet:

FieldSet
├── FieldLegend
└── FieldGroup
    ├── Field
    │   ├── Checkbox
    │   └── FieldLabel
    └── Field
        ├── Checkbox
        └── FieldLabel

Checked State

Use defaultChecked for uncontrolled checkboxes, or pair checked with onCheckedChange to control the state.

Controlled Checkbox

Indeterminate

Pass the indeterminate prop to render the mixed state — useful for "select all" controls whose children are partially selected.

Indeterminate

Invalid State

Set aria-invalid on the checkbox and data-invalid="true" on the surrounding Field to show invalid styles.

Invalid

Examples

Basic

Pair the checkbox with Field and FieldLabel for proper layout and labeling.

Basic

Description

Use FieldContent and FieldDescription for helper text alongside the label.

By clicking this checkbox, you agree to the terms and conditions.

With Description

Disabled

Add the disabled prop to the checkbox and data-disabled="true" on the Field to apply disabled styles to the label as well.

Disabled

Group

Use FieldSet and FieldLegend to semantically group related checkboxes.

Show these items on the desktop:
Checkbox Group

Table

Use checkboxes inside a Table for row selection. Apply data-state="selected" to the TableRow to style selected rows.

NameEmailRole
Sarah Chensarah.chen@example.comAdmin
Marcus Rodriguezmarcus.rodriguez@example.comUser
Priya Patelpriya.patel@example.comUser
David Kimdavid.kim@example.comEditor
In a Table

API Reference

Built on Base UI's Checkbox primitive — see the full API reference there. Common props:

PropTypeDefault
checkedboolean
defaultCheckedbooleanfalse
indeterminatebooleanfalse
onCheckedChange(checked: boolean) => void
disabledbooleanfalse
namestring
valuestring