Skip to content

Checkbox

A native checkbox, restyled: label and description, an indeterminate state, two sizes, and CheckboxGroup with an optional select-all row.

On this page
Used for
  • Accept terms
  • Pick tools for an agent
  • Select all rows
  • Notification options

Examples

Installation

npx knowns-ui@latest add checkbox
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

label / description
ReactNode
Clicking the label toggles the box.
indeterminate
boolean
Defaultfalse
Shows a dash; screen readers hear “mixed”. A click still toggles checked.
size
"sm" | "md"
Default"md"
14 or 16px box.
…input props
checked, defaultChecked, onChange, disabled, name…
Everything else goes to the native input.
CheckboxGroup legend / description
ReactNode
On a fieldset and legend, so the group is named.
options
{ value, label, description?, disabled? }[]
One checkbox each.
value / defaultValue / onValueChange
string[] / string[] / (values) => void
Default[]
The checked values.
selectAll
string
Label of a parent row that checks or clears every enabled option, with a dash when only some are on.
name / size / disabled
string / "sm" | "md" / boolean
Passed to every checkbox.

What it handles

  1. 01Restyles a native checkbox, so form submission, the label click and the keyboard work as the browser defines them.
  2. 02Shows a dash and reports aria-checked mixed through the indeterminate prop, which it sets on the DOM property in an effect.
  3. 03Adds a label and a muted description beside the box, in sm 14px or md 16px, and dims both when the box is disabled.
  4. 04Reads the checked and indeterminate colour from --kn-accent, falling back to --primary.
  5. 05Ships CheckboxGroup, a fieldset with a legend, a description, a name that submits one entry per checked value, and a group-wide disabled flag.
  6. 06Gives CheckboxGroup a select-all row whose box is checked, dashed or empty from selectAllState, and toggleAll leaves disabled options as they are.

States

First render
Nothing. The box paints in its checked or empty state
none
Check
The fill takes the accent colour and the tick scales in from 90% while fading in
120ms, ease out
Uncheck
The fill and the tick fade back out
120ms, ease out
Indeterminate
A dash fades in across the box
120ms, ease out
Keyboard focus
A focus ring appears around the box
none, at once
Disabled
The box and its label dim
none, at once

Works with

When to use

When to use

  • Independent yes or no choices, and lists with select all.

When not to use

  • A setting that applies right away: use Switch.
  • Exactly one of several options: use Radio Group.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Checkbox to my app and wire it to my own data.
  • I need independent yes or no choices, and lists with select all. Set that up with the Knowns UI Checkbox.
  • Which Checkbox props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "checkbox" }) and search_docs({ query: "checkbox" }).

Need help?

Stuck on Checkbox, or found something off? We read every message.