Checkbox

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

inputs
form
selection
toggle

Preview

Code

TSX
1
2
3
4
5
6
7
8
9
10
11
import { Checkbox } from "@/components/ui/checkbox"
import { Label } from "@/components/ui/label"

export function CheckboxDemo() {
  return (
    <div className="flex items-center space-x-2">
      <Checkbox id="terms" />
      <Label htmlFor="terms">Accept terms and conditions</Label>
    </div>
  )
}

API Reference

PropTypeDefaultDescription
checkedboolean-Whether the checkbox is checked.
defaultCheckedboolean-Whether the checkbox is checked by default.
onCheckedChangefunction-Event handler called when the checked state changes.
disabledbooleanfalseWhether the checkbox is disabled.