Checkbox

A control for a binary or tri-state choice, built on Radix Checkbox. Supports the indeterminate state a “select all” needs. It's the same control the DataTable uses for row selection.

Installation#

# One-time setup (tokens + lib helpers)npx koalaui-cli@latest init# Add this component (its dependencies come along)npx koalaui-cli@latest add checkbox

Usage#

usage.tsxTSX
import { Checkbox } from "@/components/ui/checkbox"export function Example() {  return (    <label htmlFor="terms" className="flex items-center gap-2.5">      <Checkbox id="terms" defaultChecked />      Accept terms and conditions    </label>  )}

States#

Checked and indeterminate both fill with the accent (brand) color; indeterminate shows a minus rather than a check. Drive the tri-state by passing checked="indeterminate".

Unchecked
Checked
Indeterminate
Disabled
Disabled checked

Sizes#

sm (16px) sits inside dense tables; md (20px) is the default for forms. The indicator scales with the box.

sm
md

With a label#

Checkbox renders only the box; pair it with a <label htmlFor> for an accessible name and a larger hit target. With a description, nudge the box to the first line.

Select all (indeterminate)#

A parent checkbox reads true when all children are checked, "indeterminate" on a partial selection, and false when none are. The same pattern the DataTable header uses.

FAQ#

Use a Checkbox for selecting items in a set or accepting terms, especially where a tri-state or select-all is involved. Use a Switch for toggling a single setting on or off that takes effect immediately.