# Checkbox

Binary or indeterminate choice control built on Radix Checkbox, paired with `CheckboxGroup` for `<fieldset>` + `<legend>` grouping.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| size | "xs" \| "sm" \| "md" \| "lg" | "md" | Checkbox box size (--control-icon-*) and minimum clickable row height (--control-height-*). |
| label | ReactNode | — | Inline label rendered to the right of the control; makes the entire row clickable. |
| description | ReactNode | — | Optional helper text wired into aria-describedby. |
| checked | boolean \| "indeterminate" | — | Controlled state; "indeterminate" sets aria-checked="mixed" and renders a Minus icon. |
| disabled | boolean | false | Disables toggling using step 3 background and step 8 text without opacity. |

### CheckboxGroup props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| label | ReactNode | required | Group heading rendered inside <legend>. |
| description | ReactNode | — | Helper text wired into aria-describedby on the fieldset. |
| error | ReactNode | — | Error text rendered with role="alert" and wired to aria-invalid on child checkboxes. |
| orientation | "vertical" \| "horizontal" | "vertical" | Layout direction for child checkboxes. |
| required | boolean | false | Appends a required indicator to the group legend. |

## Sizes and tokens

| Tier / Role | Token | Value |
| --- | --- | --- |
| xs | --control-icon-xs / --control-height-xs | 16px box · 24px row min-height · radius-xs (2px) |
| sm | --control-icon-sm / --control-height-sm | 16px box · 32px row min-height · radius-xs (2px) |
| md | --control-icon-md / --control-height-md | 20px box · 40px row min-height · radius-sm (4px) |
| lg | --control-icon-lg / --control-height-lg | 24px box · 48px row min-height · radius-sm (4px) |
| Unchecked / Checked | --input / --primary / --primary-foreground | Step 8 border on background · brand step 9 fill with Check or Minus |

## Code

```tsx
import { Checkbox, CheckboxGroup } from "@freshgemui/monoplinth";

export function Example() {
  return (
    <CheckboxGroup
      label="Notification channels"
      description="Choose at least one channel."
      required
    >
      <Checkbox name="channels" value="email" label="Email" defaultChecked />
      <Checkbox name="channels" value="sms" label="SMS" />
    </CheckboxGroup>
  );
}
```

## Do and don't

- **Do: Provide label or aria-label and use CheckboxGroup for related options** — Use the built-in label prop for clickable rows, or pass aria-label when rendering a bare checkbox inside a table cell.
- **Don't: Wrap Checkbox in Field** — Field places labels above controls; use Checkbox's inline label prop or CheckboxGroup instead.

## Accessibility

- Clicking anywhere on the `Checkbox` row (label, description, or gap) toggles the control while keeping `<label>` scoped so `description` does not inflate the accessible name.
- `checked="indeterminate"` sets `aria-checked="mixed"` and displays a `Minus` icon.
- `Space` toggles the checkbox; `:focus-visible` renders a `2px` `--ring` outline with `2px` offset.
- `CheckboxGroup` renders `<fieldset>` and `<legend>`, wiring `description` and `error` via `aria-describedby` and `aria-invalid`.

## Rationale

Sizing the checkbox box to `--control-icon-*` while keeping the row target height at `--control-height-*` guarantees every size meets WCAG 2.5.8's 24×24px minimum target without making the box itself oversized.
