Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Checkbox for React and Tailwind

Control for multiple selections in a set.

You'll receive a notification when someone posts a comment

Installation

bunx --bun shadcn@latest add https://kit.dev/r/checkbox.json

Anatomy

Checkbox
├── CheckboxLabel
├── checkboxVariants
└── CheckboxIndicator

Usage

import { Checkbox } from "@/components/ui/checkbox";
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldGroup,
  FieldLabel,
} from "@/components/ui/field";
<FieldGroup className="max-w-sm">
  <Field orientation="horizontal">
    <Checkbox defaultChecked />
    <FieldLabel>Accept terms and conditions</FieldLabel>
  </Field>
  <Field orientation="horizontal">
    <Checkbox />
    <FieldContent>
      <FieldLabel>Receive notifications</FieldLabel>
      <FieldDescription>
        You'll receive a notification when someone posts a comment
      </FieldDescription>
    </FieldContent>
  </Field>
  <Field orientation="horizontal">
    <Checkbox />
    <FieldContent>
      <FieldLabel>Receive marketing emails</FieldLabel>
    </FieldContent>
  </Field>
</FieldGroup>

Accessibility

KeyDescription
Space
Activate the focused control.

Demos

Card

Checkbox Group

Context

Controlled

Default Checked

Disabled

Form

Group Controlled

Group Form

Group Invalid

Group Max Selected

Group Provider

Group Select All

Indeterminate

Invalid

Read Only

Root Provider

With Description

With Field

API Reference

Checkbox

label

PropType
AttributeType

checkboxVariants

div

PropType

CheckboxIndicator

div

PropType
AttributeType

CheckboxGroup

div

PropType
AttributeType

CheckboxGroupProvider

div

PropType
AttributeType

CheckboxRootProvider

label

PropType
AttributeType

useCheckbox

PropType

CheckboxContext

PropType