Checkbox

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

Loading example…

Installation

bunx --bun shadcn@latest add @sui/checkbox

Install with the shadcn CLI or use the shared @workspace/ui package. Follow the installation guide to configure the registry, load styles, and choose import aliases.

Usage

import { Checkbox } from "@workspace/ui/components/checkbox"
<Checkbox />

Checked State

Use defaultChecked for uncontrolled checkboxes, or checked and onCheckedChange to control the state.

import * as React from "react"

export function Example() {
  const [checked, setChecked] = React.useState(false)

  return <Checkbox checked={checked} onCheckedChange={setChecked} />
}

Invalid State

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

Loading example…

Basic

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

Loading example…

Description

Use FieldContent and FieldDescription for helper text.

Loading example…

Disabled

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

Loading example…

Group

Use multiple fields to create a checkbox list.

Loading example…

Table

Loading example…

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

Loading example…

API Reference

See the Base UI documentation for more information.