Skip to content
Pixelbits
Docs / Checkbox
Forms

Checkbox

A native checkbox, styled: it stays a real <input type="checkbox">, so forms, keyboard and screen readers work without JavaScript. When checked, the box fills in three pixel steps.

Controlled with checked + onCheckedChange, or uncontrolled with defaultChecked.

Installation

npm: import
import { Checkbox } from "pixelbits/checkbox";
shadcn: copy the source
npx shadcn add https://pixelbits.ali-moradi-develop.com/r/checkbox.json

API

<Checkbox>

A native checkbox, styled: it stays a real <input type="checkbox">, so forms, keyboard and screen readers work without JavaScript. When checked, the box fills in three pixel steps.

Controlled with checked + onCheckedChange, or uncontrolled with defaultChecked.

Example
<Checkbox label="Email notifications" defaultChecked />
<Checkbox label="Select all" indeterminate={some && !all} checked={all} onCheckedChange={toggleAll} />
PropTypeDefaultDescription
labelReactNode—

Text next to the box; clicking it toggles the box.

descriptionReactNode—

Smaller text under the label, linked with aria-describedby.

indeterminatebooleanfalse

The mixed state (a dash), for a "select all" box whose children are only partly checked. Screen readers announce it as "mixed".

onCheckedChange(checked: boolean) => void—

Called with the new checked state. The native onChange still works too.

Also accepts every prop of Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "children">.