enhancement: Toggle switch component in the UI kit
Back to our planProblem
The kit has no on/off toggle switch, so the showcase's light and dark toggle (and any future on/off setting in a form) has nothing to be built from.
Proposed fix
- Native first: the kit builds its controls on Radix (
@radix-ui/react-checkbox, tabs, dialog…). Use Radix Switch (@radix-ui/react-switch), vetted by the security guideline, before any custom code; record the finding here. - A
Switchinsrc/platform/ui/, styled only from theme tokens, with a visible label, keyboard and screen-reader support, and a touch target large enough for a phone. - Usable on its own and through
Fieldin a form.
Existing work compared
Searched open and closed issues on 2026-11-26 (showcase, Storybook, gallery, toggle, switch, developer site, examples, theme readiness, usage, side navigation). Part of epic #1528, which replaces #1424 (owner decision 2026-11-26, recorded there). No other issue covers this step.
Acceptance criteria
- Not done: Tests first: on and off by click, keyboard (Space) and label; the checked state announced; disabled; an axe check in light and dark
- Not done: Only theme tokens; a 44 px touch target; visible focus
- Not done: A gallery entry and a row in
docs/ui/component-set.md(guard rail 5, until the showcase replaces the gallery), and the UI kit note says what it does - Not done: Visual design review at phone and desktop widths, light and dark
Files likely touched
src/platform/ui/Switch.client.tsx, src/platform/ui/Switch.client.test.tsx, src/platform/ui/Field.client.tsx, src/platform/ui/README.md, docs/ui/component-set.md, src/app/(frontend)/dev/gallery/FieldsGallery.client.tsx, src/app/(frontend)/dev/gallery/galleryComponents.ts, package.json, package-lock.json
Must not touch
src/modules/, src/payload.config.ts
Open questions
None.
Area
frontend, styling
Priority
priority: medium
Generated by Claude Code, opens in a new tab