Checkbox

PreviousNext

A control that allows users to toggle between checked and unchecked states with support for indeterminate state.

Component checkbox-demo not found in registry.

Installation

pnpm dlx shadcn@latest add checkbox

Usage

import * as Checkbox from "@/components/ui/checkbox"
 
export default function CheckboxDemo() {
  return (
    <div className="flex items-center space-x-2">
      <Checkbox.Root id="terms" />
      <label htmlFor="terms" className="text-sm font-medium">
        Accept terms and conditions
      </label>
    </div>
  )
}

Examples

States

Component checkbox-states not found in registry.

With Text

Component checkbox-with-text not found in registry.

Controlled

Component checkbox-controlled not found in registry.

Props

Checkbox

This component is based on the Radix UI Checkbox primitive and supports all of its props.

Prop

Type

Default

checked
boolean
'indeterminate'
-
defaultChecked
boolean
-
onCheckedChange
(checked: boolean | 'indeterminate') => void
-
disabled
boolean
-
required
boolean
-
name
string
-
value
string
-
className
string
-