Components

Checkbox

A hand-drawn box you tick. Checking fills it with solid marker and writes a heavy felt tick over it, stroke by stroke; a dash means partly checked. Radix behavior, keyboard and form support are untouched.

Install

terminal
npx shadcn@latest add @wobko/checkbox

First time here? Add the registry to components.json first. How to install

Examples

Default

Tick it and watch the felt tick get written. Clicking the label works too.

States and sizes

Off, on, partly on, invalid and disabled in 16, 20 and 28 px. The label of a disabled box fades with it (peer-disabled).

Select all

A parent box that shows the dash when only some children are ticked, and a Field-like row whose hover lights the box.

In a form

Boxes with a name and value submit like native checkboxes; required blocks the submit until the box is ticked.

With a description

A label and a line of help beside the box. Field keeps the box level with the first line of text however long the help runs, and `data-disabled` on the Field dims the label and the help together with the disabled box.

The whole card is the checkbox

The shadcn demo's bordered label. Wrap a Field in a FieldLabel and the pair becomes a hand-drawn card; when the box inside is ticked the card gets a highlighter wash and a felt outline. Click anywhere on it, or Tab to the box and press Space.

API reference

Checkbox

Radix Checkbox.Root (a <button role="checkbox">, plus Radix's hidden native input inside a form) with the drawing behind it. Size it with size-*: 16, 20 and 28 px are drawn and tested. The tick is written with ll-draw when the state turns checked or indeterminate (instantly with reduced motion).

PropTypeDefaultDescription
checkedboolean | "indeterminate"-Controlled state. "indeterminate" draws the dash and reports aria-checked="mixed".
defaultCheckedboolean-Initial state when uncontrolled.
onCheckedChange(checked: boolean | "indeterminate") => void-Called on click and Space.
disabledbooleanfalseDashed pencil box on a pale wash, graphite tick when on. Not focusable, no hover.
aria-invalidboolean | "true" | "false"-true draws the box in red pencil.
name / value / required / formstring | boolean-Forwarded to Radix's hidden input, so the value is in FormData ("on" unless you give value) and forms validate and reset.
seedstring | number-Pins the hand: the same seed always draws the same box and tick. Default: derived from useId().

Accessibility

  • role="checkbox" with aria-checked true, false or mixed; Space toggles, Tab focuses, Enter is left to the form (Radix).
  • Label it with <Label htmlFor>, wrap it, or use aria-label. A Label next to it is a peer: peer-disabled dims it, and hovering the label (a Field row with group/field, or a label right after the box) lights the box's hover overlay.
  • The hit area is 8 px larger than the box on every side (an ::after, so layout never moves): 28 px for the 16 px box.
  • Keyboard focus draws a blue felt ring; the drawing is aria-hidden, pointer-events: none and never focusable. Windows high contrast replaces it by a real border.
  • The tick is drawn on with a stroke reveal (0.3 s). Reduced motion (the OS setting or data-motion="reduced") shows the finished mark at once.
  • Right-to-left layouts need nothing: the box is symmetric and every offset is logical.

Source

The files the CLI copies into your project.

Loading the source