---
title: "Checkbox"
description: "A box that people check to turn one option on or off in a form. It has checked, mixed, invalid, disabled, and read-only states in 2 sizes."
url: https://gelatinui.com/components/checkbox
markdown_url: https://gelatinui.com/components/checkbox.md
access: free
install: "npx shadcn@latest add @gelatin-ui/checkbox"
registry_item: https://gelatinui.com/r/checkbox.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Checkbox

> A box that people check to turn one option on or off in a form. It has checked, mixed, invalid, disabled, and read-only states in 2 sizes.

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

## When to use it

Best for: An option that a form sends when people press Save or Submit.

- Use it for an option that the form sends when people press Save or Submit.
- Use a Checkbox Group for options that share one value, a list of names.
- Use `indeterminate` for a parent box when only some of its options are checked.

## When not to use it

- For a setting that takes effect at once, use a [Switch](https://gelatinui.com/components/switch.md).
- To pick one option from a list, use radio buttons.

## Notes for agents

- Name it with a `Label` around it or a `Field`; the box alone has no text.
- A `CheckboxGroup` holds one value for all its boxes: the list of the checked names.

## Anatomy

```text
Checkbox
└─ CheckboxMark (0..n)
```

## API reference

### Checkbox

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `size` | `"default" \| "lg"` |  | `default` 16px, or `lg` 20px. Default: the `CheckboxGroup` size, else `default`. |

Also takes every prop of Base UI `Checkbox.Root`: https://base-ui.com/react/components/checkbox

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Checkbox | `checkbox` | `data-disabled`, `data-readonly` | `--radius` |  |
| CheckboxMark | `checkbox-check` | `data-shown`, `data-size` |  | `motion-timing` |

## Usage

The value is `checked`, a boolean. Put the box first inside a `Label`, so the full row toggles it.

The sample also uses `label`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/checkbox @gelatin-ui/label
```

```tsx title="terms-checkbox.tsx"
import { useState } from "react";

import { Checkbox } from "@/components/ui/checkbox";
import { Label } from "@/components/ui/label";

export function TermsCheckbox() {
  const [accepted, setAccepted] = useState(false);
  return (
    <Label>
      <Checkbox name="terms" required checked={accepted} onCheckedChange={setAccepted} />
      I accept the terms of service
    </Label>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/checkbox
```

It adds 6 registry items: 3 files, 1321 lines, and the npm packages `@base-ui/react`, `@phosphor-icons/react`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Switch](https://gelatinui.com/components/switch.md): Pick Switch for a setting that takes effect at once, with no Save button.
- [Label](https://gelatinui.com/components/label.md)
- [Field](https://gelatinui.com/components/field.md)
- [Toggle](https://gelatinui.com/components/toggle.md): Pick Toggle for a button that stays on or off in a toolbar, such as bold or mute, with the effect at once.
- [Radio Group](https://gelatinui.com/components/radio-group.md): Pick Radio Group when people must pick exactly one option from a short list.

## Keyboard

| Keys | Action |
| --- | --- |
| Space | Checks or clears the box. |

## Accessibility

Checkbox is a Base UI `Checkbox.Root`: a `<span>` with `role="checkbox"` and `aria-checked` (`true`, `false`, or `mixed` when `indeterminate`), and a hidden native input for the form. It also sets `aria-readonly` and `aria-required`.

Name it with a `Label`, or with `FieldLabel` in a `Field`. Base UI reads the label of the hidden input and sets `aria-labelledby` on the box.

The check and the dash are hidden from screen readers (`aria-hidden`), because `aria-checked` says the state. The focus ring shows on keyboard focus only. An invalid box (`aria-invalid`) shows a red edge and ring.

The box is 16px (`lg` 20px). On a coarse pointer, `hit-area` grows the touch target to at least 44 × 44px.

## Motion

| Part | Motion |
| --- | --- |
| Check | fade · 150ms · ease-out (0, 0, 0.2, 1) · the mark fades in and grows from 60% |
| Swap check and dash | fade-exit · 90ms out, fade · 150ms in · ease-out (0, 0, 0.2, 1) |
