Checkbox
A control that allows the user to toggle between checked and not checked.
By clicking this checkbox, you agree to the terms.
Installation
Composition
Use the following composition to pair a Checkbox with a label:
Field
├── Checkbox
└── FieldLabelTo add a description, wrap the label and helper text in FieldContent:
Field
├── Checkbox
└── FieldContent
├── FieldLabel (or FieldTitle)
└── FieldDescriptionTo group related checkboxes, nest Fields inside a FieldGroup and FieldSet:
FieldSet
├── FieldLegend
└── FieldGroup
├── Field
│ ├── Checkbox
│ └── FieldLabel
└── Field
├── Checkbox
└── FieldLabelChecked State
Use defaultChecked for uncontrolled checkboxes, or pair checked with onCheckedChange to control the state.
Indeterminate
Pass the indeterminate prop to render the mixed state — useful for "select all" controls whose children are partially selected.
Invalid State
Set aria-invalid on the checkbox and data-invalid="true" on the surrounding Field to show invalid styles.
Examples
Basic
Pair the checkbox with Field and FieldLabel for proper layout and labeling.
Description
Use FieldContent and FieldDescription for helper text alongside the label.
By clicking this checkbox, you agree to the terms and conditions.
Disabled
Add the disabled prop to the checkbox and data-disabled="true" on the Field to apply disabled styles to the label as well.
Group
Use FieldSet and FieldLegend to semantically group related checkboxes.
Table
Use checkboxes inside a Table for row selection. Apply data-state="selected" to the TableRow to style selected rows.
| Name | Role | ||
|---|---|---|---|
| Sarah Chen | sarah.chen@example.com | Admin | |
| Marcus Rodriguez | marcus.rodriguez@example.com | User | |
| Priya Patel | priya.patel@example.com | User | |
| David Kim | david.kim@example.com | Editor |
API Reference
Built on Base UI's Checkbox primitive — see the full API reference there. Common props:
| Prop | Type | Default |
|---|---|---|
checked | boolean | — |
defaultChecked | boolean | false |
indeterminate | boolean | false |
onCheckedChange | (checked: boolean) => void | — |
disabled | boolean | false |
name | string | — |
value | string | — |