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

The CheckboxGroup component groups related checkbox options.

PropTypeDefault
classNamestring-

CheckboxField

The CheckboxField component renders the checkbox label.

PropTypeDefault
classNamestring-

Checkbox

The Checkbox component renders the checkbox label.

PropTypeDefault
classNamestring-

See the React Aria for the full API reference.