GitHub
DocsCheckbox

Checkbox

A control that allows the user to toggle between checked and unchecked states.

Preview

Installation

npx shadcn@latest add checkbox

Usage

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

<div className="flex items-center space-x-2">
  <Checkbox id="terms" />
  <Label htmlFor="terms">Accept terms and conditions</Label>
</div>

Props

checked — controlled checked state

defaultChecked — initial checked state (uncontrolled)

onCheckedChange — callback fired on change

disabled — disables the control