UI.MD

Checkbox

A control that toggles between checked and unchecked states.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/checkbox.json

Usage

import { Checkbox } from "@/components/ui/checkbox"

Examples

Default

Wrap the box and its text in one Label so the whole row toggles, gap included. A label sitting next to the checkbox instead leaves a dead strip people click on and nothing happens.

Sizes

14, 16, and 20px. The check icon scales with the box, so size is the only thing you set.

With description

A second line under the label. Indent it past the box (pl-6 is the 16px box plus the 8px gap) so it lines up with the title rather than hanging under the checkbox.

API Reference

PropTypeDefaultDescription
size"sm" | "default" | "lg""default"The checkbox size: sm (14px), default (16px), or lg (20px). The check icon scales to match.
checkedboolean | "indeterminate"-The controlled checked state. Use with onCheckedChange.
defaultCheckedboolean-The initial checked state when uncontrolled.
onCheckedChange(checked: boolean | "indeterminate") => void-Called when the checked state changes.
disabledbooleanfalseDisables the checkbox and dims it to 70% opacity.