Checkbox

Loading...

Installation

Install the component via the CLI in one command.

npx shadcn@latest add @intentui/checkbox

Composed components

When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.

Manual installation

Use this approach if you prefer to install and wire up the component yourself instead of using the CLI.

npm install react-aria-components @heroicons/react tailwind-merge

Anatomy

import { Checkbox, CheckboxField } from "@/components/ui/checkbox"
import { Description } from "@/components/ui/field"
<CheckboxField>
  <Checkbox>Remember me</CheckboxLabel>
  <Description>Keep me logged in on this device</Description>
</CheckboxField>

Examples

Invalid

The checkbox is in an error state.

Loading...

Description

You can add a description to checkbox by adding Description component as a child of CheckboxField.

Loading...

Indeterminate

The checkbox is in an indeterminate state.

Loading...

Controlled

You can control the checkbox value by using the value prop.

Loading...

Uncontrolled

You can control the checkbox value by using the defaultValue prop.

Loading...

Disabled

The checkbox is disabled.

Loading...

Component API

CheckboxGroup

CheckboxGroup extends the React Aria Components <CheckboxGroup> component.

classNamestring

CheckboxField

CheckboxField extends the React Aria Components <CheckboxField> component.

classNamestring

Checkbox

Checkbox extends the React Aria Components <CheckboxButton> component.

classNamestring

See the React Aria for the full API reference.

Design