Repository navigation
Description
Context
Part of #2576.
(ThemeToggle, packages/ui-react/src/components/layout/theme.tsx:39-68) renders role="radiogroup" with three <button role="radio"> options (System, Paper, Dark). Every option is its own tab stop and the arrow keys do nothing. The radio pattern requires one tab stop with arrows moving and selecting inside the group, and the kit already fixed this defect for its own groups (design-feedback.md §11, "Every tab and radio in the kit was its own tab stop"). It renders in Settings, Appearance & input (packages/ui-react/src/components/settings/settings-panel.tsx:207).
Native radio inputs supply the whole contract: one tab stop, arrows that move and select, and a checked state that assistive technology already knows. Guide html/html: "DO use <button> for triggered actions … and <a> strictly for URL navigation". Selection is neither of those, so it belongs on a radio input.
Scope
- Render the group as a
<fieldset>(orrole="radiogroup"container) named "Theme", holding three<label>s that each contain a visually hidden<input type="radio" name=… value=…>and the visible label text.onChangecallssetTheme. - Move the selected and hover paint onto the label:
label:has(:checked)for selected andlabel:has(:focus-visible)for the focus ring. The currentbk-rowhover veil andtitlehint stay. - Remove the
raw-button: selectmarker, since no raw button remains.
Out of scope
- Theme logic (
useUIStoretheme/setTheme,useApplyTheme). - Changing the option set, labels, order or paint.
- Other radiogroups (kit groups already rove).
Acceptance criteria
- Tab reaches the group once. ArrowLeft/Right/Up/Down move and select, Space selects, and Tab leaves the group.
- The accessibility tree exposes a group named "Theme" with three radios, one checked, matching
useUIStoretheme. - Selected, hover and focus paint match the current baselines in both themes, at 320px and ≥900px.
- A browser keyboard test (one Tab stop, ArrowRight changes the theme) fails on the current tree and passes after. Record the failing-first run in the PR.
-
packages/ui-react/tests/render/render-smoke.test.tsxandpackages/ui-react/tests/browser/remaining-buttons.cases.tsxare updated to the new roles.
Verification
bun run test packages/ui-react/tests/render/render-smoke.test.tsx
node scripts/visual.mjs --project=ui-react-layout --filter=settings
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
ThemeToggle takes no props, and only its rendered elements change.
Activity