Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Checkbox examples · Standard

Indeterminate Checkbox for React

A checkbox that starts indeterminate, the dash that stands for a partial selection.

Framework
UI library

A checkbox can be neither checked nor unchecked. This one starts in the indeterminate state, the dash that tells people some, but not all, of what it stands for is selected. The state is controlled, and the first click moves it to checked; after that it toggles like any other box. Use it for select-all boxes over lists and table rows, as in the nested list.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

When should I use indeterminate state?

On a parent checkbox when only some of its children are checked: a select-all over a list, a permission group partly granted, a table with a few rows selected. A plain yes-or-no never needs it.

How do I manage indeterminate state in React?

This demo holds the state and starts it at indeterminate. The first change stores the next checked value. Pass indeterminate while the dash should show, and checked as a boolean. onCheckedChange receives the next boolean.

What does indeterminate look like visually?

Base UI marks the box indeterminate, but the indicator in the checkbox file only holds a CheckIcon: render a MinusIcon there for the indeterminate state to show a dash.

What happens when users click an indeterminate checkbox?

The first click stores the next boolean, so the dash becomes a check. The click after that clears it. The box is controlled, so both moves go through the same handler.

How do screen readers announce indeterminate state?

As "mixed" or "partially checked", depending on the screen reader. The checkbox exposes the mixed state. Give the box a label that says what it covers, like "Select all features", so "mixed" means something.

How do I sync indeterminate parent with child checkboxes?

This file is one checkbox, so the dash is the starting value, not a count of children. For a parent over real children, derive that value each render: all checked, none, or some. When the parent changes, set every child to the next boolean.