# Checkbox · JGuang UI

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

- Page: https://jiguang132.com/systems/jguang-ui/docs/components/radix/checkbox
- Based on: shadcn/ui documentation (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c

> Example `checkbox-demo`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/checkbox


## Installation


  

**Command**


  

**Manual**


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Install the following dependencies:


```bash
npm install radix-ui
```


### Copy and paste the following code into your project.


[View complete source: components/ui/checkbox.tsx](/r/jguang-ui/radix/checkbox.json)


### Update the import paths to match your project setup.


## Usage

```tsx
import { Checkbox } from "@/components/ui/checkbox"
```

```tsx
<Checkbox />
```

## 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 <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.


> Example `checkbox-invalid`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/checkbox


## Basic

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


> Example `checkbox-basic`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/checkbox


## Description

Use `FieldContent` and `FieldDescription` for helper text.


> Example `checkbox-description`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/checkbox


## Disabled

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


> Example `checkbox-disabled`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/checkbox


## Group

Use multiple fields to create a checkbox list.


> Example `checkbox-group`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/checkbox


## Table


> Example `checkbox-table`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/checkbox


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> Example `checkbox-rtl`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/checkbox


## API Reference

See the [Radix UI](https://www.radix-ui.com/docs/primitives/components/checkbox#api-reference) documentation for more information.

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
