structyl

Checkbox

stable

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

Basic usage

Examples

Indeterminate state

Use the indeterminate state for a "select all" parent checkbox.

Checked, unchecked and indeterminate

Checkbox supports standard and indeterminate states for bulk selection flows.

Semantic colors

Use the color prop to visually reinforce the meaning of each checkbox option.

Features

  • Supports indeterminate state.
  • Full keyboard navigation.
  • Can be controlled or uncontrolled.

Installation

bash
pnpm dlx structyl add checkbox

API Reference

Checkbox

A checkbox supporting an indeterminate state.

PropTypeDefault
checkedboolean | 'indeterminate'

Controlled checked state.

defaultCheckedboolean | 'indeterminate'

Initial checked state when uncontrolled.

onCheckedChange(checked) => void

Called when the checked state changes.

disabledboolean

Disable the checkbox.

false
requiredboolean

Mark as required.

false
namestring

Name for form submission.

classNamestring

Additional Tailwind classes, merged with the component defaults.

Keyboard interactions

Adheres to the WAI-ARIA design pattern .

KeyDescription
SpaceToggles the checkbox.
Checkbox | structyl