# Checkbox

A checkbox, including a mixed state for partly selected groups.

- **Use it for**: An independent yes or no, or several items picked from a short list.
- **Not for**: A setting that takes effect immediately. Try [Switch](https://unseenui.com/components/switch/), [RadioGroup](https://unseenui.com/components/radio-group/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { Checkbox } from '@stackunseen/ui';
import { Field } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Field label="Include documentation"><Checkbox checked={included} onCheckedChange={setIncluded} /></Field>
```

## Props

- `checked` (`boolean (optional)`): The controlled checked state. Update it when the user changes the selection.
- `onCheckedChange` (`(checked: boolean) => void (optional)`): Receives the next checked value. Use it with checked for a controlled checkbox.
- `indeterminate` (`boolean (optional)`): Shows a mixed selection. It does not change checked or the submitted value.
- `name` (`string (optional)`): The key used in native form data.
- `disabled` (`boolean (optional)`): Prevents changes and excludes the checkbox from native form submission.

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `description` | `ReactNode` | Help text under the label, announced as the checkbox's description. |
| `indeterminate` | `boolean` |  |
| `label` | `ReactNode` | A visible label beside the box. |
| `onCheckedChange` | `((checked: boolean) => void)` |  |

## Keyboard

Tab focuses the checkbox; Space toggles it. Its associated label can also activate it.

## Works with

[Field](https://unseenui.com/components/field/), [Input](https://unseenui.com/components/input/), [Textarea](https://unseenui.com/components/textarea/), [Select](https://unseenui.com/components/select/), [Switch](https://unseenui.com/components/switch/), [Alert](https://unseenui.com/components/alert/), [Button](https://unseenui.com/components/button/), [RadioGroup](https://unseenui.com/components/radio-group/), [TonePad](https://unseenui.com/components/tone-pad/), [Slider](https://unseenui.com/components/slider/), [InputGroup](https://unseenui.com/components/input-group/), [Combobox](https://unseenui.com/components/combobox/)

Page: https://unseenui.com/components/checkbox/
