Files
coder/site/e2e/tests/users
christin 4dfec5c966 fix(site): use shared radio for theme cards (#30833)
The theme cards on Settings > Appearance used a hidden native radio plus
a hand-built indicator, so #30462 did not cover them. The indicator used
`border-default` when unselected and `border-secondary` when selected,
which fails WCAG 1.4.11:

| | Before | After |
|---|---|---|
| Dark, unselected | `#27272A` on `#09090B`, 1.34:1 | `#71717A`, 4.12:1
|
| Dark, selected | `#3F3F46`, 1.91:1 | `#71717A`, 4.12:1 |
| Light, unselected | `#E4E4E7` on white, 1.27:1 | `#71717A`, 4.83:1 |
| Light, selected | `#A1A1AA`, 2.56:1 | `#71717A`, 4.83:1 |

The cards now use the shared `RadioGroup` and `RadioGroupItem`, so they
get the same `border-control` rest and hover borders as the Terminal
font radios. The whole card is still the click target, the blue ring
still marks the selected card, and the card focus outline is unchanged.
Values were measured from computed styles on the dev server.

Fixes DEQ-285

## Before and after

Settings > Appearance, Theme mode "Single". Light default is selected in
light mode, Dark default in dark mode.

| | Before | After |
|---|---|---|
| Dark | <img width="420"
src="https://raw.githubusercontent.com/coder/coder/assets/a11y-theme-card-radio-contrast/before-dark.png"
/> | <img width="420"
src="https://raw.githubusercontent.com/coder/coder/d486b79633c92c32fecb7457703a5db1e8e44a43/after-dark.png"
/> |
| Light | <img width="420"
src="https://raw.githubusercontent.com/coder/coder/assets/a11y-theme-card-radio-contrast/before-light.png"
/> | <img width="420"
src="https://raw.githubusercontent.com/coder/coder/d486b79633c92c32fecb7457703a5db1e8e44a43/after-light.png"
/> |

<details>
<summary>Decision log</summary>

- **Shared component instead of restyling the custom indicator.** Keeps
the theme cards in sync with every other radio, so future token changes
apply here too.
- **Keyboard behavior now matches the Terminal font radios.** With the
native radio, Arrow keys moved focus and immediately switched (and
saved) the theme. With the shared `RadioGroup`, Arrow keys move focus
and Space selects, which is how the Terminal font radios on the same
page already behave. Verified on the dev server: Tab focuses the
selected card, Arrow moves focus, Space selects and saves.
- **Accessible names are unchanged.** Each radio is labelled by its card
(`htmlFor`/`id`, the same pattern as the Terminal font radios), and the
group is a `radiogroup` named "Theme". The existing AppearanceForm
stories that select themes by role and name pass.
- **Group role changes from `group` to `radiogroup`.** The old
`<fieldset>` exposed `group`; the shared component exposes `radiogroup`,
which is the correct role for a set of radios. The e2e test `adjust user
theme preference` queried the old role, so its locator is updated.
- The Terminal font radios in the same ticket were fixed by #30462, so
this closes DEQ-285.

</details>

---

_Generated by Coder Agents on behalf of @chrifro._
2026-10-16 11:20:31 +02:00
..