Skip to content

Checkbox

A checkbox for one boolean field value, with an indeterminate state.

Export secret values in plain text inside the DSL file.

Omit execution traces from the exported package.

hero.tsx

Usage guidelines

  • Use Checkbox for one boolean field value saved with its form, or for one option inside CheckboxGroup. Use CheckboxGroup for several values from a visible set, Switch for an on/off setting that takes effect immediately, and Toggle for the pressed state of a button.
  • Label the checkbox with a visible FieldLabel that wraps it, so clicking the text toggles it. Use aria-label only when no visible label exists, because a non-blank aria-label overrides the associated label.
  • Use indeterminate when the checkbox summarizes a partial selection. It is controlled by the owner, which clears it once the user decides. Inside CheckboxGroup, a parent checkbox derives the mixed state on its own.
  • Checkbox renders a <span> with a hidden <input> beside it. Set name, value and uncheckedValue for native form submission.
  • Use disabled for a value the user cannot change, and say why in FieldDescription. readOnly keeps the value visible and focusable without allowing changes.

Anatomy

tsx
tsx

Checkbox owns its indicator: a check mark when checked and a dash when indeterminate.

Examples

Indeterminate

indeterminate shows the mixed state and sets aria-checked="mixed". The owner turns it off when the user picks a side.

3 of 8 members already have the editor role.

indeterminate.tsx

Disabled

Set disabled on Field to disable the checkbox and its label together. The description explains why the value is fixed.

Your workspace signs in through SSO only.

Required by your Enterprise plan.

disabled.tsx

Read-only

readOnly keeps the checkbox focusable, readable and included in form submission without allowing changes.

Locked by workspace policy. Focusable and submitted with the form, but cannot be toggled.

read-only.tsx

Keyboard

KeyAction
SpaceToggles the focused checkbox.
TabMoves focus to the next control. A disabled checkbox is skipped.

API reference

Checkbox

A checkbox control supporting checked, unchecked, and indeterminate states. Renders a <span> element and a hidden <input> beside.

Pair with a visible FieldLabel or <label>; use aria-label only when no visible label exists.

Base UI Checkbox.Root docs

Data attributes
AttributeDescription
data-checked

Present when the checkbox is checked.

data-unchecked

Present when the checkbox is not checked.

data-indeterminate

Present when the checkbox is in an indeterminate state.

data-disabled

Present when the checkbox is disabled.

data-readonly

Present when the checkbox is readonly.

data-required

Present when the checkbox is required.

data-valid

Present when the checkbox is in a valid state (when wrapped in Field.Root).

data-invalid

Present when the checkbox is in an invalid state (when wrapped in Field.Root).

data-touched

Present when the checkbox has been touched (when wrapped in Field.Root).

data-dirty

Present when the checkbox's value has changed (when wrapped in Field.Root).

data-filled

Present when the checkbox is checked (when wrapped in Field.Root).

data-focused

Present when the checkbox is focused (when wrapped in Field.Root).

CheckboxSkeleton

Accepts the props of the element it renders.