Default
Tick it and watch the felt tick get written. Clicking the label works too.
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.
npx shadcn@latest add @wobko/checkbox第一次使用?先把 registry 加进 components.json。 如何安装
Tick it and watch the felt tick get written. Clicking the label works too.
Off, on, partly on, invalid and disabled in 16, 20 and 28 px. The label of a disabled box fades with it (peer-disabled).
A parent box that shows the dash when only some children are ticked, and a Field-like row whose hover lights the box.
Boxes with a name and value submit like native checkboxes; required blocks the submit until the box is ticked.
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 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.
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).
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| checked | boolean | "indeterminate" | - | Controlled state. "indeterminate" draws the dash and reports aria-checked="mixed". |
| defaultChecked | boolean | - | Initial state when uncontrolled. |
| onCheckedChange | (checked: boolean | "indeterminate") => void | - | Called on click and Space. |
| disabled | boolean | false | Dashed pencil box on a pale wash, graphite tick when on. Not focusable, no hover. |
| aria-invalid | boolean | "true" | "false" | - | true draws the box in red pencil. |
| name / value / required / form | string | boolean | - | Forwarded to Radix's hidden input, so the value is in FormData ("on" unless you give value) and forms validate and reset. |
| seed | string | number | - | Pins the hand: the same seed always draws the same box and tick. Default: derived from useId(). |
CLI 会复制进你项目的文件。
正在加载源码