# Checkbox

> Source: https://design.nanatec.co.ke/components/checkbox/
> A form-associated checkbox. Works inside a native `<form>`, supports the indeterminate state, and offers `card` / `toggle` tile variants for selection UIs.

A form-associated checkbox. Works inside a native `<form>`, supports the indeterminate state, and offers `card` / `toggle` tile variants for selection UIs.

## Preview

```html
<nana-checkbox>Accept terms and conditions</nana-checkbox>
```

## Installation

```bash
npm install @nana-tec/ui-components
```

## Import

```js
import "@nana-tec/ui-components/checkbox";
```

## Basic usage

```html
<nana-checkbox>Accept terms and conditions</nana-checkbox>
```

## Sizes

```html
<nana-checkbox size="sm">Small</nana-checkbox>
<nana-checkbox size="md">Medium</nana-checkbox>
<nana-checkbox size="lg">Large</nana-checkbox>
```

## States

```html
<nana-checkbox checked>Checked</nana-checkbox>
<nana-checkbox indeterminate>Indeterminate</nana-checkbox>
<nana-checkbox disabled>Disabled</nana-checkbox>
<nana-checkbox checked disabled>Checked &amp; disabled</nana-checkbox>
```

## API

## Events

| Event | Type | Description |
|---|---|---|
| `nana-change` | `CustomEvent` | Fired on toggle (`detail.checked`, `detail.indeterminate`) |

## Slots

| Slot | Description |
|---|---|
| `(default)` | The label (overrides the `label` attribute) |
| `description` | Secondary descriptive text |

## CSS Variables

| Variable | Default | Description |
|---|---|---|
| `--nana-checkbox-accent` | — | Checked background / border colour |
| `--nana-checkbox-radius` | — | Box corner radius |

## CSS Parts

| Part | Description |
|---|---|
| `control` | The clickable row |
| `box` | The check box |
| `label` | The label text |

## Accessibility

<ul class="a11y-grid not-content">
  <li>Keyboard accessible</li>
  <li>Screen-reader labels</li>
  <li>Focus-visible states</li>
  <li>ARIA roles and states</li>
  <li>WCAG 2.2 AA contrast</li>
</ul>

## Related components

<ul class="related not-content">
  <li><a href="/components/button/">Button</a></li>
  <li><a href="/components/button-group/">Button Group</a></li>
  <li><a href="/components/icon-button/">Icon Button</a></li>
  <li><a href="/components/input/">Input</a></li>
  <li><a href="/components/textarea/">Textarea</a></li>
</ul>

## Storybook

See every state and prop interactively in Storybook: https://storybook.nanatec.co.ke/?path=/docs/components-checkbox--docs
