---
title: Checkbox
description: A control that allows the user to toggle between checked and not checked.
base: base
component: true
links:
doc: https://base-ui.com/react/components/checkbox
api: https://base-ui.com/react/components/checkbox#api-reference
---
## Installation
Command
Manual
```bash
npx shadcn@latest add checkbox
```
Install the following dependencies:
```bash
npm install @base-ui/react
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Usage
```tsx
import { Checkbox } from "@/components/ui/checkbox"
```
```tsx
```
## Checked State
Use `defaultChecked` for uncontrolled checkboxes, or `checked` and
`onCheckedChange` to control the state.
```tsx showLineNumbers
import * as React from "react"
export function Example() {
const [checked, setChecked] = React.useState(false)
return
}
```
## Invalid State
Set `aria-invalid` on the checkbox and `data-invalid` on the field wrapper to
show the invalid styles.
## Examples
### 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 `` component for disabled styles.
### Group
Use multiple fields to create a checkbox list.
### Table
## RTL
To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl).
## API Reference
See the [Base UI](https://base-ui.com/react/components/checkbox#api-reference) documentation for more information.