Checkbox

Checkbox

Markdown

A checked, unchecked, or indeterminate control for selection and acknowledgment.

Use Checkbox when people can select zero or more options or affirm a statement. Use Switch for a setting that takes effect immediately.

Checkbox group

Installation

$npx shadcn@latest add @patchui/checkbox

The copied source is available in the registry JSON. The canonical implementation lives in packages/react/src/components/checkbox.tsx.

Usage

<Checkbox>Send weekly digest</Checkbox>

Passing children creates a clickable label. Bare checkboxes require an accessible name.

Examples

Selection states

Indeterminate communicates partial collection selection. Application state still determines what happens on the next change.

Selection states

API reference

Checkbox accepts the underlying Base UI checkbox props. These fields coordinate Patch UI behavior.

PropTypeDefaultDescription
childrenReactNode-Adds a visible label and expands the click target.
checked / onCheckedChangeboolean / (checked: boolean, details) => void-Controls checked state.
defaultCheckedbooleanfalseSets the initial uncontrolled state.
indeterminatebooleanfalseDisplays partial selection while application state remains authoritative.
wrapperClassNamestring-Styles the generated label wrapper when children are present.

Accessibility

  • Give every bare Checkbox a specific aria-label, such as Select Ada Lovelace.
  • Group related checkboxes with fieldset and legend.
  • Clear indeterminate state when the controlled collection becomes fully selected or unselected.