# Checkbox and radio

> Checkboxes pick any number; radios pick exactly one, with every option in sight. Native boxes in the project’s accent, labels that say what is true when checked.

Source: https://kwark.space/designSystem/components/checkbox-and-radio

## Usage

### What it is
Kwark uses the browser’s own checkbox and radio, coloured with the project’s accent through `accent-color` (`StorySurface.css`). Native boxes stay readable by every assistive tool, follow the platform’s high-contrast modes, and never drift out of step with keyboard behaviour.

- **Checkbox**: independent yes/no choices, saved with the form: *Scene numbers in both margins*, *Revision marks*.
- **Radio**: exactly one of two to five, all visible: *A4* or *US Letter*.

### When to use which
| Need | Use |
|---|---|
| Any number of independent options | Checkboxes |
| Exactly one, all options worth reading | Radios |
| One of two or three, as a mode | [Segmented control](https://kwark.space/designSystem/components/segmented-control.md) |
| Applies the moment it changes | [Switch](https://kwark.space/designSystem/components/switch.md) |
| One of many | [Select](https://kwark.space/designSystem/components/select.md) |

### Writing labels
- Say what is true when checked: *Revision marks*, not *Show revision marks?*
- Put the consequence in a hint under the label, in plain words: *60 lines a page*; *Prints in colour; leave off for a black-and-white copier.*
- A disabled option says why: *This script has no outline yet.* Structure is optional (Decision 0003); the option waits, it does not push.

### Behaviour
- The whole label is the target; at 44px tall on touch.
- Radios start with the current or most common value chosen; never leave a radio group with nothing chosen.
- A required group shows its error under the group, naming what it blocks.

**Do:** *Revision marks* — *An asterisk in the right margin beside each changed line.*

**Don't:** *Revision marks?* with no hint, and a custom-drawn box that ignores Space.

## Style

### Anatomy

1. **Box**: native, 16px, `accent-color: var(--k-accent)`; 2px down so it sits on the first line of text.
2. **Grid**: box and text in two columns (16px, then the rest), 10px apart, so hints align with the label text, not under the box.
3. **Label**: 14px `--k-text`, line height 1.4. **Hint**: 12px `--k-text-2` at 1.45, 1px below.
4. **Rows**: 6px above and below (10px on touch), stacked with 4px between.
5. **Group**: a `fieldset` without a border; the `legend` is the field label (500 12px).
6. **Disabled**: label in `--k-text-2`, `not-allowed` cursor, the reason as the hint.
7. **Error**: the legend in `--k-danger` and the message under the group, tied to the fieldset; the boxes stay native.

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-accent` | #98633f | #98633f |
| `--k-accent-soft` | #e8b58b | #e8b58b |
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-text-2` | #5b6779 | #9ca3af |
| `--k-danger` | #b4382c | #e0685c |
| `--k-fs-body` | 14px |  |
| `--k-fs-meta` | 12px |  |

## Code

### React

Use the HTML below with `kwark.css`. The example shows the markup and styling. Supply any application behavior described on this page.

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<div class="kw-specimen-row">
<fieldset class="kw-choices"><legend class="kw-label">Print with</legend>
  <label class="kw-choice"><input type="checkbox" checked><span>Scene numbers in both margins</span></label>
  <label class="kw-choice"><input type="checkbox" checked><span>Revision marks<small>An asterisk in the right margin beside each changed line.</small></span></label>
  <label class="kw-choice"><input type="checkbox"><span>Character colours<small>Prints in colour; leave off for a black-and-white copier.</small></span></label>
  <label class="kw-choice"><input type="checkbox" disabled><span>The outline in the margin<small>This script has no outline yet.</small></span></label>
</fieldset>
<fieldset class="kw-choices"><legend class="kw-label">Paper</legend>
  <label class="kw-choice"><input type="radio" name="kw-paper" checked><span>A4<small>60 lines a page</small></span></label>
  <label class="kw-choice"><input type="radio" name="kw-paper"><span>US Letter<small>55 lines a page</small></span></label>
</fieldset>
</div>
<fieldset class="kw-choices kw-choices--invalid" aria-describedby="kw-cr-err"><legend class="kw-label">Send Rev 4 to</legend>
  <label class="kw-choice"><input type="checkbox" aria-invalid="true"><span>Cast</span></label>
  <label class="kw-choice"><input type="checkbox" aria-invalid="true"><span>Camera and lighting</span></label>
  <label class="kw-choice"><input type="checkbox" aria-invalid="true"><span>Production office</span></label>
  <span class="kw-error" role="alert" id="kw-cr-err"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 8v4M12 16h.01"/></svg>Choose at least one group to send the call sheet to.</span>
</fieldset>
```

## Accessibility

### Keyboard
| Key | Checkbox | Radio group |
|---|---|---|
| Tab | Each checkbox | Into the group (the chosen radio), then out |
| Space | Toggles | Chooses the focused radio |
| Arrow keys | — | Move and choose within the group |

### Rules
- Native inputs, never hidden behind a drawn box that loses focus.
- Group radios, and related checkboxes, in a `fieldset` with a `legend`.
- A group error is tied to the fieldset with `aria-describedby` and announced once.
- Focus shows the 2px `--k-accent-soft` ring 2px off the box.

## For agents

### Rules

- **Must** use native checkbox and radio inputs, coloured with accent-color.
- **Must** wrap radio groups in a fieldset with a legend.
- **Always** write a label that states what is true when checked, with consequences in a hint.
- **Never** leave a radio group with nothing chosen.
- **Always** give a disabled option its reason in words.

### AI readiness test

**Task:** Build the print options for a screenplay export.

**Give the agent:** Checkbox and radio, Print and export pattern.

**Constraint:** Paper size is one of A4 or US Letter; scene numbers and revision marks are optional.

**A reliable answer:**
- Radios for paper in a fieldset with line counts as hints
- Checkboxes for scene numbers and revision marks
- Labels state what is true
- Native inputs with accent-color
