Make your AI a shadcn expert

Shadcn Checkbox

React checkbox for terms, filters, and table row selection. Built with TypeScript and Tailwind CSS for Next.js using Base UI — checked, unchecked, or indeterminate.

A checkbox is a yes or no. Click the box or its label and the check appears. Use it for terms, filters, and picking rows — anything that waits for submit. If it should take effect now, that is a Switch.

Scroll to load preview...

Looking for a neobrutalism version for shadcn?

Same checkbox, thicker borders. The NeoBrutalism checkbox is the kit if you want that look.

Usage

import { Checkbox } from "@/components/ui/checkbox"
import { Field, FieldLabel } from "@/components/ui/field"
<Field orientation="horizontal">
  <Checkbox id="terms" name="terms" />
  <FieldLabel htmlFor="terms">Accept terms and conditions</FieldLabel>
</Field>

defaultChecked for an uncontrolled box. checked plus onCheckedChange when you own the state.

Composition

Checkbox

The indicator is inside the root. Pair it with Field for the label.

Invalid State

aria-invalid on the checkbox. data-invalid on the Field. Both, or the label stays the wrong color.

Scroll to load preview...

Basic

Pair it with Field and FieldLabel so the words are the click target.

Scroll to load preview...

Description

FieldContent plus FieldDescription for the helper line under the label.

Scroll to load preview...

Disabled

disabled on the checkbox, data-disabled on the Field so the label greys out with it.

Scroll to load preview...

Group

A FieldSet of horizontal Fields. Each row is its own checkbox.

Scroll to load preview...

Table

A checkbox in the header selects the page. One per row selects that record.

Scroll to load preview...

RTL

Wrap with DirectionProvider and dir="rtl". Labels stay Arabic.

Scroll to load preview...

API

Prop

Type

Keyboard

KeyAction
SpaceToggle the focused checkbox
TabMove to the next control

Notes

Invalid needs two attributes

aria-invalid on the checkbox, data-invalid on the Field. One without the other leaves the control or the label unstyled.

checked="indeterminate" is paint, not a posted value. The form still sends checked or not.

With other components

Questions

Was this page helpful?

Sign in to leave feedback.