# Checkbox

> A checkbox under a cap of clear glass: the box and its mark are always seen through the lens.

```tsx
import { useState } from 'react'

import { Checkbox } from '@/components/liquid-glass/controls/Checkbox'

export default function Demo() {
  const [remember, setRemember] = useState(true)
  return (
    <div className="flex flex-col gap-4">
      <Checkbox label="Remember this device" checked={remember} onChange={setRemember} />
      <Checkbox label="Circle" shape="circle" checked={false} />
    </div>
  )
}
```

**Use it for**

- Choosing any number of items in a list or a form.
- Agreeing to something that is submitted later.

**Not for**

- A setting that takes effect at once: use Switch.
- One choice out of several: use Tabs.

```bash
npx shadcn@latest add https://onemorethink.dev/r/checkbox.json
```

## Usage

```tsx
import { Checkbox } from '@/components/liquid-glass/controls/Checkbox'

const [remember, setRemember] = useState(true)

<Checkbox label="Remember this device" checked={remember} onChange={setRemember} />
```

The glass cap is there at rest, not only while pressed. Needs `three` and UI SDK, like Slider.

## Examples

### Colours

```tsx
import { Checkbox } from '@/components/liquid-glass/controls/Checkbox'

// `color` is the box while checked. Without it the checkbox is the kit's blue.
export default function Demo() {
  return (
    <div className="flex flex-col gap-5">
      <Checkbox label="Blue" />
      <Checkbox label="Green" color="#34c759" />
      <Checkbox label="Orange" color="#ff9500" />
      <Checkbox label="Pink" color="#ff2d55" />
    </div>
  )
}
```

`color` is the box while checked; without it the checkbox is the kit's blue. The mark stays white.

## API reference

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `checked` | `boolean` | `true` | Checked or not. |
| `onChange` | `(checked: boolean) => void` | — | Called with the new state. |
| `label` | `string` | `'Remember this device'` | Text beside the box; an empty string leaves the box alone. |
| `description` | `string` | — | A second, quieter line under the label. |
| `name` | `string` | — | Submits with the form around it under this name. |
| `shape` | `'rounded' \| 'circle'` | `'rounded'` | A rounded square or a circle. |
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Box size 18, 22 or 28 px. |
| `color` | `string` | `'#3291FF'` | The box while checked: a hex, `rgb()` or named colour, not a CSS variable. |
| `theme` | `'light' \| 'dark'` | — | Overrides the page theme for this checkbox. |
| `disabled` | `boolean` | `false` | Dimmed and not interactive. |
| `swell` | `number` | `1.18` | How much the cap grows while pressed. |

## Accessibility

- A `<button role="checkbox">` with `aria-checked`: Space toggles it.
- The `label` is a real `<label>` tied to the button.
- With reduced motion the mark and the cap change without springs.

Source: https://onemorethink.dev/docs/checkbox
