feat: Tabs component for the UI kit, readable without JavaScript
Back to our planProblem
In plain words: a post sometimes has three or four views of the same thing (day-to-day money, big projects, one home). Tabs let a neighbor pick one without a long scroll. Today the kit has no tabs.
Summary of the owner's feedback (2026-11-03, Claude in Chrome side panel, text) on the first version of the 2027 budget post: the title is too long and the explanation under it is confusing; the amounts are not grouped in consistent categories, and they don't show how much of the total each one makes up or how this year compares with last year; the icons sit above the text, and the subheader could share a line with the icon. Most importantly, there are not enough visual cues for anyone to follow what is going on, so more diagram elements, charts, infographics and other UI elements are needed, with inventive, unconventional thinking, as if written by someone on a small marketing project who knows nothing about taxes. Design spec and numbers: see #645 and the epic #589.
Today (checked 2026-11-03): src/platform/ui/ has Disclosure (a native <details>, which pushes later content down) and Radix Dialog, Select and Checkbox, but no tabs.
Proposed fix
- Native first (checked):
<details name>gives an exclusive accordion but no tab semantics, and panels push each other down, which breaks the one-screen layout. Radix Tabs (@radix-ui/react-tabs) gives the standard accessible pattern (roving focus, arrow keys, ARIA) and matches the Radix pieces we already use. Add it at an exact version; runnpm audit. src/platform/ui/Tabs.client.tsx:<Tabs label items={[{ value, trigger, heading, panel }]} defaultValue />.- All panels render on the server (
forceMount), so charts passed in as children stay server-rendered and no chart code reaches the browser. - Readable without JavaScript: add
@custom-variant scripted (@media (scripting: enabled))totailwind.css; inactive panels getscripted:data-[state=inactive]:hidden. With scripting off, the tab list is hidden and every panel shows stacked under its visible heading. Check that Radix leaveshiddenoff whenforceMountis set; if not, override it in the kit. - No layout shift on load (the server sets
data-statefromdefaultValue). Panel change is a 150ms fade,motion-safeonly. - Gallery entry and a
component-set.mdrow. Watch out: a new shared component.
Acceptance criteria
- Not done: Keyboard: arrows, Home and End move between tabs; the selected tab is announced ("tab, 1 of 3").
- Not done: With scripting off (simulated), all panels show with headings; with it on, only one does.
- Not done: No layout shift at load; axe passes; works at 320 and 1280, light and dark.
- Not done: Test, gallery entry and
component-set.mdrow are in the PR.
Area
frontend, ux
Priority
high
Generated by Claude Code, opens in a new tab