Reference
ADR 0005: shadcn components on Paprika's closed theme
Note (2026-11): the app described here,
web-legacy, was replaced byapps/weband removed from the tree; paths to it below are historical and no longer resolve.
- Status: Superseded by ADR 0009 (2026-11-29)
- Date: 2026-11-22
- Amends: ADR 0003: Tailwind CSS for the canvas app UI (the constraints stay; this ADR adds how a component library lives under them)
- Code:
web-legacy/src/components/ui/(primitives),web-legacy/src/styles.css(semantic aliases),web-legacy/src/lib/cn.ts,web-legacy/components.json, gallery on/ui(web-legacy/src/UiGallery.tsx) - Board:
docs/en-US/assets/boards/PAP-B-030(drawn in Paprika before any dependency was installed)
#Context
The backlog row "Migrate the UI to shadcn components" was pulled forward from batch 4 to batch 3 (requested 2026-11-22). Nine UI tickets were already in the queue, and one ticket that migrated everything would have collided with all of them, so the migration is split into five: PAP-B-030 (this one: the foundation), then PAP-B-031 (overview and dialogs), PAP-B-032 (inspector), PAP-B-033 (shell, toolbar, layers, pages) and PAP-B-034 (team panel and agent roster). Tickets already in flight keep using src/ui.ts; they move onto the primitives after 030 lands.
Two things about ADR 0003 make this a decision and not a package install:
- No Preflight. shadcn's components are written against Preflight, which resets margins, sets
border: 0 solidon everything, makesbuttonbackgrounds transparent andsvgblocks. Paprika cannot have it: the document under.worldmust render on browser defaults, exactly like the HTML export andrender_screenshot. - A closed theme. The brand names in
styles.cssare already taken with Paprika's meaning:text-mutedis a text color (#a6acc4) andbg-accentis the brand red. shadcn usesmutedfor a surface andaccentfor a hover surface. Overriding those names would repaint the whole app.
#Decision
Copy the code, keep the theme. Components are copied into
web-legacy/src/components/ui/(shadcn's open-code model, stylenew-york, MIT). Nothing renders through a component library at runtime beyond Radix primitives: nonode_modulescomponent, no build-time registry. Each copied file says where it came from, andweb-legacy/components.jsonrecords the source style for the ones still to come.Semantic names, namespaced
ui-. The shadcn names —background,foreground,card,popover,primary,secondary,muted,accent,destructive,border,input,ring— are defined in the@theme staticblock ofstyles.cssas--color-ui-*, each pointing at an existing brand token:shadcn name Paprika variable dark (Estúdio noturno) light mirror ( .ui-light)background / foreground --color-ui-background/-foregroundnight#141827 /fg#eef0f7#f2f3f8 / #141827 card / card-foreground --color-ui-card/-foregroundpanel#1e2336 /fg#ffffff / #141827 popover / popover-foreground --color-ui-popover/-foregroundpanel-2#272d45 /fg#ffffff / #141827 primary / -foreground / -hover --color-ui-primary*accent-strong#c8401f / white /accent-dark#a93220same secondary / -foreground / -hover --color-ui-secondary*panel-2/fg/ #313a5ccanvas#e7e9f0 / #141827 / #d9deeamuted / muted-foreground --color-ui-muted*panel-2/muted#a6acc4canvas/ #5d6478accent / accent-foreground --color-ui-accent*panel-2/fgcanvas/ #141827destructive / -foreground / -hover --color-ui-destructive*danger#cc2f50 / white /danger-dark#a31d3d — its own hue, not the accent, see Danger colorsame fill and hover; the text token becomes #a8173a destructive as text --color-ui-destructive-textdanger-ink#ff9fb2 (7.01:1 onpanel-2)#a8173a (7.37:1 on white) border / input --color-ui-border/-inputline#2c3350#d3d7e3 / #c6cbd9 ring (focus) / link --color-ui-ring/-linkselect#4cc7d8#0b7183 overlay behind dialogs --color-ui-overlayrgb(9 12 22 / .66) rgb(20 24 39 / .42) The
ui-prefix is what keeps ADR 0003 intact:text-mutedandbg-accentgo on meaning what they meant, and a primitive never reads them. One token has no upstream equivalent: red as text needs its own token. The fill red #c8401f carries white text at 4.99:1, but written as text onpanel-2it is only 2.72:1, so menu items, validation messages and the alert icon read--color-ui-destructive-text(7.97:1 dark, 6.28:1 light).What the primitives take from Preflight is written into the primitives, not into a global rule. The base layer of
styles.csskeeps exactly the rules ADR 0003 listed. Nothing global was added for shadcn, because a globalbutton { background: transparent }or* { border-color: … }would repaint today's panels and reach into the canvas. Instead every primitive names its own background, border color and, where upstream relies on Preflight's reset, its ownm-0:DialogTitle,DialogDescription,AlertDialogTitleand the others areh2/p, and without Preflight they carry the UA margins.Focus is an outline, not a ring. The app already signals focus with
focus-visible:outline-2 focus-visible:outline-offset-2. The primitives use the same, withoutline-ui-ring. The ring utilities exist in the theme (--color-ui-ring) for the future, but the copied components were changed: in the night theme a 1px ring inside a red button is invisible, and Paprika's own controls already use the outline.Density is Paprika's, not shadcn's. Root font 13px,
--spacing: 4px(ADR 0003), soButtonsizes are 24/28/32/36px (xs/sm/default/lg, plusicon) and fields are 28px tall — the numbers drawn on the board, and the sizes the current panels use. Upstream'sh-9default would make the inspector a third taller. Thesm:/md:responsive tweaks in the upstream files were dropped: the closed theme has one breakpoint (wide, 901px), and an unknown variant produces a class that compiles to nothing.Dark is the shipped theme; light is a token scope.
.ui-lightredefines only the--color-ui-*variables, so a light panel can sit next to a dark one and the future "Theme modes (light/dark/compact)" backlog row has one place to grow from. The app itself does not switch themes in this ticket. Radix renders overlays in a portal on<body>, so the gallery passes the scope class onto the content element (<DialogContent className="ui-light">) — the theme travels with the portal.Animations come from
tw-animate-css. Importing it adds the enter/exit utilities (animate-in,animate-out,fade-in-0,slide-in-from-top-2,animate-collapsible-down) used by dialog, popover, menu, tooltip, select and collapsible, which also covers part of the backlog row "Better on-screen animations with tailwind-animate". Version 1.4.0 ships no reduced-motion guard, sostyles.cssadds one, scoped:not(.world, .world *)like the scrollbar rules: underprefers-reduced-motion: reducethe animation still runs at 0.01ms so Radix, which unmounts onanimationend, still closes. The inspector collapsible is the exception (PAP-B-088):animate-collapsible-down/-upsetheightfrom--radix-collapsible-content-height, and that measured height jumped and clipped the last row.CollapsibleContentanimatesgrid-template-rowsbetween0frand1frinstead, so no frame is taller than the settled body; the same 0.01ms guard keeps reduced motion to one step, and the body unmounts onanimationend.cn()isclsx+tailwind-mergeconfigured for the closed theme (src/lib/cn.ts):text-2xs/xs/sm/md/lg/xl/tileare declared as font sizes sotext-mdis not read as a color, andshadow-float/shadow-tagas shadows so they replace upstream'sshadow-md/shadow-lginstead of sitting next to them.Dependencies, pinned and licensed (
web-legacy/package.json, exact versions, no range):radix-ui1.8.1 (MIT, one package, imported as namespaces:import { Dialog as DialogPrimitive } from "radix-ui"),class-variance-authority0.7.1 (Apache-2.0),clsx2.1.1 (MIT),tailwind-merge3.7.1 (MIT) as runtime dependencies, andtw-animate-css1.4.0 (MIT) as a devDependency next totailwindcss, since it is CSS consumed at build time. PAP-B-047 addscmdk1.1.1 (MIT) for the Command primitive used by the FontPicker combobox.components.jsonrecords the layout, without a@/alias. The repo imports with relative paths, and adding TSpathsplus a Vite alias was not in this ticket. Consequence:npx shadcn add <name>will generate@/lib/utilsimports that do not resolve here, so a future add is a manual copy with the same two rewrites we did by hand —@/…→ relative, and the color names →ui-*.The proof surface is
ConnectionStatus, and the gallery is the comparison tool. Onlyweb-legacy/src/ConnectionStatus.tsxmigrates in this ticket: it renders throughcomponents/ui/status.tsx(StatusLiveRegion,statusDotVariants) withcn()and theui-*tokens, with the same DOM and the same text, so the existing accessibility assertion on the live region keeps covering it. The visible dot in the top bar stays where it is becauseApp.tsxbelongs to PAP-B-033;statusDotVariantsis where it will land./uirenders every primitive in both scopes, unlinked from the app and lazy-loaded, so the app chunk does not pay for the primitives before their screens migrate.
#What was changed relative to upstream
| upstream (new-york, 2026-11) | here | why |
|---|---|---|
bg-primary, text-muted-foreground, border-input |
bg-ui-primary, … |
the brand names of ADR 0003 are taken with another meaning |
focus-visible:ring-1 ring-ring |
focus-visible:outline-2 outline-offset-2 outline-ui-ring |
matches the app's existing focus; a 1px ring is invisible on a filled control |
h-9 controls, px-4 |
28px fields, 24/28/32/36px buttons | density of the 13px root / 4px spacing scale, as drawn on the board |
bg-black/80 dialog scrim |
bg-ui-overlay |
the night brand, and the same value the board carries |
shadow-md/shadow-lg |
shadow-float |
the theme defines two shadows; the board uses the floating one |
text-destructive for red text |
text-ui-destructive-text |
2.72:1 as text on the night surfaces, 7.97:1 with the ink |
AlertDialogAction is always the primary button |
ConfirmDialog swaps in the destructive classes through className |
a delete confirmation must not look like the app's main call to action |
sm:/md: variants |
removed | the closed theme has one breakpoint (wide) |
React.forwardRef + displayName |
function components, ref as a prop (React 19), data-slot |
the current upstream style; data-slot is also what the E2E suite selects |
import { X } from "@radix-ui/react-x" |
import { X as XPrimitive } from "radix-ui" |
one MIT package instead of thirteen |
Close label in the dialog |
"Fechar", aria-label on the button |
the app UI is pt-BR, and an icon-only control keeps its accessible name |
#Danger color and the confirmation pattern (PAP-B-026)
Paprika's accent is red, so the primitive's default mapping — destructive = accent-strong — made the delete
button and the main call to action the same button. The answer, drawn first and merged in PR #95, is a hue of
its own: the brand token --color-danger #cc2f50, --color-danger-dark #a31d3d for the hover and
--color-danger-ink #ff9fb2 as text (#a8173a in .ui-light), which the --color-ui-destructive* aliases point
at. Danger stays a filled red button; what separates it from the primary is the hue, not the treatment.
Measured by the accessibility suite, in both theme scopes: white on the fill is 5.13:1 at rest and 7.50:1 on hover; written as text, the ink is 7.01:1 on the night surfaces and 7.37:1 on white. The test also asserts the danger fill is not the primary's color.
The other candidate, drawn on the same sheet before #95 and rejected, borrowed the app's existing warning
language: the accent as a translucent wash with accent-ink as the text. It lost on both counts — a wash of the
accent reads as a quiet primary rather than as danger, and in the light scope its hover alpha had to be capped at
14% to keep the text above 4.5:1. With a hue of its own the button can stay filled and the hover can get
darker, which is what a danger action is expected to do.
Two rules say what receives the treatment:
- Danger marks what Ctrl+Z cannot bring back. Deleting a workspace and removing a member from a team carry
it. Deleting a node, a page or a selection is undoable and stays neutral — painting every delete red would
make red mean nothing. Rotating an instance key and revoking invite links are irreversible too but were left
alone: the ticket scoped
Team.tsxto the remove-member button. - An irreversible action gets a confirmation with the verb in it — and a workspace delete also asks for the
workspace's name typed.
ConfirmDialog(web-legacy/src/ConfirmDialog.tsx) composes the AlertDialog primitive: verb in the title, what is lost in the description,Cancelarfirst, the destructive action last, and the error inside the dialog, because the page banner sits behind the scrim. Radix opens an AlertDialog with the focus on cancel, which is the safe default.
Still missing, and tracked in the backlog: the canvas toast naming what an agent deleted or which workspace an
agent switched to. It reads the summary delete_workspace returns, which is PAP-B-015 (PR #97); the notice
itself has no ticket yet.
#Verification
pnpm check(build with the WASM renderer, typecheck, fixtures, TS and Go tests, API and E2E suites against the Go server).packages/e2e/test/e2e/a11y.e2e.test.ts, PAP-B-026: the workspace-delete confirmation is asserted as analertdialogwhose buttons come in the orderCancelarthenExcluir, whose action carries the destructive classes, whose focus starts inside it and returns to the trigger on Esc, and whose Esc leaves the workspace on the list; the destructive button is measured at 4.5:1 or better in both theme scopes, at rest and on hover (the wash is translucent, so the test composes it over the panel behind it before measuring).packages/e2e/test/e2e/canvas.e2e.test.ts: the overview flow reads that confirmation by rolealertdialoginstead ofdialog, and types the workspace name where it previously clicked straight through; the assertions themselves (Cancel keeps it, Excluir removes it, deleting the active workspace moves the canvas and the agents) are unchanged.packages/e2e/test/e2e/a11y.e2e.test.ts, new block "galeria de primitivas (/ui)": the dialog traps focus and eight Tab presses stay inside, Esc returns focus to the trigger; the alert dialog opens with focus inside and itsui-lightscope travels with the portal; the tooltip opens from the keyboard, not only on hover; the menu opens with Enter, names its items (menuitem, including the destructive one), moves with arrows and closes with Esc; the primary button passes 4.5:1 in both theme scopes; and underprefers-reduced-motion: reducethe chrome animations are neutralized while a node inside.worldkeepstransition-duration: 0sand the.worldcontainer keepsline-height: normal.- Isolation of the canvas: the canvas E2E suite and the WASM suite (which compares the DOM renderer with the Rust one, pixel by pixel) are unchanged and pass. On top of that, the same canvas page (
/w/<id>over the Go server, 1440×900, Chromium) was screenshotted onorigin/mainand on this branch: 0 of 1.296.000 pixels differ. Nothing in this ticket touches the DOM under.world— every new rule is either a utility class on a primitive or a:not(.world, .world *)scope. - Bundle,
vite buildonorigin/mainand on this branch: CSS 29.02 kB → 45.94 kB (6.59 kB → 9.12 kB gzip); the app entry JS 554.31 kB → 585.85 kB (170.30 kB → 181.03 kB gzip), which iscn()plus the migratedConnectionStatus; the primitives and Radix sit in the lazy gallery chunk, 179.69 kB (52.46 kB gzip), loaded only on/ui. They move into the app chunk as PAP-B-031…034 migrate each screen. - Board before code: five frames on the
Interfacespage of the Paprika workspace (controls and overlays, light and dark, plus the token map), drawn over MCP at127.0.0.1:4777beforepnpm addran, withlint_designat 0 errors, exported todocs/en-US/assets/boards/PAP-B-030.
#Consequences
- The theme stays closed and Preflight stays out; the primitives carry their own resets.
- Two names coexist for a while:
ui.ts(until PAP-B-031…034 delete each unused entry) andcomponents/ui/.AGENTS.mdsays which one new UI code uses. PAP-B-033 freedui.iconBtnand moved the shell, toolbar (ToggleGroup+Tooltip), layers, pages,InlineName,PanelResizerand the top-bar status dot onto the primitives; Inspector (PAP-B-032) still readsui.ts. - PAP-B-051: HTML
titleattributes inweb-legacyare gone; useHint(orTooltip+TooltipTrigger+TooltipContent) fromcomponents/ui/tooltip.tsx.TooltipProviderlives once inmain.tsx. Icon-only buttons keeparia-label; wrap a disabled control in a focusablespanwhen it still needs a tip. - A light theme now exists at the token level only; the app does not offer it yet.
tw-animate-cssis the animation source, so the "tailwind-animate" backlog row is partly covered; the row stays open until the app's own animations use it.- Adding a component later is a copy plus two mechanical rewrites (paths and color names), because there is no
@/alias; that is recorded here rather than paid for with a new config surface.