Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Checkbox for React

Control for multiple selections in a set.

Installation

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

Anatomy

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

Usage

import { Checkbox } from "@/components/ui/checkbox";
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field";
<FieldGroup className="w-fit whitespace-nowrap">
  <Field orientation="horizontal">
    <Checkbox name="terms" />
    <FieldLabel>Accept terms</FieldLabel>
  </Field>
</FieldGroup>

Accessibility

KeyDescription
Space
Activate the focused control.

Demos

Invalid

Set aria-invalid on the checkbox and data-invalid on the field wrapper to show the invalid styles.

Basic

Pair the checkbox with Field and FieldLabel for proper layout and labeling.

Description

Use FieldContent and FieldDescription for helper text.

Disabled

Use the disabled prop to prevent interaction and add the data-disabled attribute to the Field for disabled styles.

Group

Use multiple fields to create a checkbox list.

Table

Checkboxes in a table for row selection.

Rtl

Right-to-left checkbox. See the RTL configuration guide for document direction.

API Reference

Checkbox

PropType
AttributeType