Skip to content

Checkbox

Download .md

A checkbox turns one option on or off, or picks several options from a list.

  • Use it for agreements and for choosing several items.
  • Use a radio group or a Select when only one choice is allowed.
  • Don’t use it for settings that apply at once; use a switch.
React
Vue
123
  1. 1Checked box on primary
  2. 2Unchecked box
  3. 3Label, also clickable

A 16px box on radius-sm (6px) with a check icon, and a label beside it. Checked boxes fill with primary.

There is one style. A checkbox can be checked, unchecked or indeterminate.

React Vue Flutter Type Default Use
checked / defaultChecked v-model / default-value value boolean false The state.
onCheckedChange @update:model-value onChanged function none Runs when the state changes.
disabled disabled enabled: false boolean false Blocks changes.
id id label string none Links the label.
import { Checkbox } from "@/components/ui/checkbox"
import { Label } from "@/components/ui/label"
export default function CheckboxDemo() {
return (
<div className="flex items-center gap-2">
<Checkbox id="checkbox-demo-terms" />
<Label htmlFor="checkbox-demo-terms">Saya setuju dengan syarat penggunaan</Label>
</div>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/checkbox.json
  • Renders role="checkbox" with aria-checked; Space toggles it.
  • Every checkbox needs a label, linked by id.