Skip to content
Toolkit

ADR-0020: Studio ships the component CSS a conversion needs, as a layer the consumer can take alone

  • Status: Accepted
  • Date: 2026-08-19
  • Deciders: Renaissance workstream 002, phase 02 (ConfirmDialog, the first conversion); follows ADR-0019

Context

Phase 01 authored six components into @studio/react. Phase 02 converts the app's call sites onto them. ConfirmDialog went first — 55 files, 63 call sites, every one of them passing a bare string, so the JavaScript side of the conversion is a one-line import swap per file and nothing else.

The conversion still did not work, and the reason had nothing to do with JavaScript.

apps/web/src/index.css imports three Studio layers: css/fonts, css/tokens and css/resource. It does not import @studio/core/css — the full stylesheet — because the app carries ~4,600 lines of its own component CSS plus its own element resets, and the bundle's 10-base.css, 30-primitives.css and shells would fight them. So the app has Studio's tokens and Studio's flow components, and nothing else.

.lk-modal, .lk-confirm__* and .lk-btn live in 50-components.css and 55-components-extended.css, which exist only inside that full bundle. A converted confirmDialog() would therefore have rendered correct, accessible, token-true markup with no stylesheet at all: an unstyled <div> stack in the top-left corner of the page. That is precisely what non-negotiable #7 ("if a control ships, it works") exists to prevent, and it is not specific to ConfirmDialog — it blocks every remaining phase 02 conversion identically. The evidence that this was already the shape of the problem: all nineteen files that import @studio/react today import only Drawer, ResourceUrl, PreviewPane and PreviewFrame — exactly the four components whose CSS the resource layer supplies. Adoption had silently stopped at the edge of the stylesheet.

Two smaller findings came with it, both the same kind of thing — a component that is correct in Studio's own preview and inert in a real consumer:

  • confirm.jsx drew its icon with <i class="ph-fill ph-warning">. Studio ships no icon font and declares no dependency on one; the app loads none. The icon tile would have rendered as a coloured empty square. resource.jsx had already hit this and already written down the answer — inline SVG, "which is what a design-system package owes its consumers" — when the drawer's close button turned out to be invisible in Cardsite.
  • ConfirmDialogHost rendered its surface inline, where the host is mounted. Everything it interrupts — the drawer, the app's modal — is portalled to document.body, so at the shared --z-overlay layer the interrupted surface, being the later sibling, painted on top of the interruption.

Decision

A Studio component's CSS ships in a layer its consumer can import on its own, and a consumer that cannot take the full stylesheet is a first-class consumer, not a special case.

Concretely:

  1. studio/scripts/build-css.mjs emits dist/studio.components.css — 50-components.css + 55-components-extended.css, the .lk- component layer — exported as @studio/core/css/components. This is the same move the build already made for studio.resource.css, one step wider, and for the same stated reason.
  2. Taking a layer alone is only safe if the layer cannot reach outside its own namespace, so the build now checks that rather than asserting it. Four ways out, all of them checked, because "leads with a .lk- class" alone is not containment: a stray subject (body { … }, or .not-lk nested inside a media query); a pseudo-class that reaches through the component to something else (:has(.lk-modal), html:has(.lk-modal), :not(.lk-nothing)); a universal reached only by sibling combinators (.lk-modal ~ * — the layer's roots are portalled to <body>, so their siblings are the whole consumer), while a universal inside the subject stays legal, because .lk-prose > * + * is the stacked-margin idiom and never leaves .lk-prose; and @keyframes names, which are one global namespace and would otherwise let the layer replace a consumer's own fade-in. Each is proved against the real build, not asserted. It is a lexical check over files Studio controls, not a CSS parser: it reads selectors, not strings, and that limit is written at the check.
  3. A component may not depend on a different layer for its own styling. .lk-icon, the inline-SVG glyph atom, lived in the resource layer; confirm.jsx is in the component layer and draws one. It moved to 50-components.css — one rule, one home — and the build appends it to the standalone resource layer so that layer still stands alone.
  4. apps/web/src/index.css imports that layer. It does not grow as conversion proceeds — the app's equivalent rules leave styles/components.css instead, which is the direction the charter's "the alias bridge empties as it goes" describes.
  5. Per ADR-0019, the two defects above are fixed in Studio, not worked around in the app: confirm.jsx draws inline SVG, and ConfirmDialogHost portals to document.body so an interruption outranks what it interrupts.

Consequences

  • Every remaining phase 02 conversion is unblocked by one import line that is now already written. Skeleton, Pagination, DataTable, DropdownMenu and Popover all render .lk- families carried in the same two files.

    Amended 2026-08-19. That last sentence has since been half-true four times, and it is what ADR-0023 was written about: a component renders its own family and whatever kit-level atoms and neighbouring-layer rules its markup happens to name. DataTable needed .visually-hidden from the a11y layer; DropdownMenu and Popover needed .glass from the material layer, four .lk-menu* rules from the shell layer and .t-label from the type layer — six rules, none of them in "the same two files". Read this line as the component's own family is carried, and run ADR-0023's enumeration for the rest.

  • The app now parses ~190 rules it does not yet use. That is the cost of taking the layer whole rather than slicing it per component, and it is the right trade: a per-component slicing mechanism is a second build system to maintain and to get wrong, and the unused rules disappear from the consumer's own sheet as each component converts.

  • Five of those rules are not unused, and this is the point. Drawer and ResourceUrl — already shipped, on 17 pages — emit lk-btn, lk-btn--icon, lk-field, lk-input and lk-help, and none of those is defined in the resource layer. Until this change they fell back to the consumer's element resets: Cardsite's drawer close button was a bare glyph, its resource-URL slug field a reset <input>. They now render as designed. That is the same defect as the blank Phosphor tile, one layer up — a component adopted without the CSS it needs is adopted in name only — and it is worth stating plainly that adopting this layer changes the appearance of surfaces that were already converted, not only of the one being converted today.

  • A component may not depend on an icon font. Six Studio React modules still emit ph-* classes (chrome, controls, feedback, overlays, shell, surfaces); each is a blank glyph in Cardsite today and is fixed as its component converts, not speculatively.

  • Studio still has no test runner of its own, but it no longer needs one to be tested: the app's vitest/jsdom unit project imports @studio/react directly, so apps/web/src/components/ConfirmDialog.test.tsx covers the converted component's behaviour, the way DrawerFocusTrap.test.tsx already did for the Drawer. A converted component's tests land there. The namespace check was watched failing on deliberately broken input before it was trusted, and the two fixes above were each proved by reverting them and watching exactly their test fail. The standing gap is recorded in .station/jobs/002-renaissance/SESSION.md.

Alternatives considered

  • Import @studio/core/css whole. Honest, and the eventual end state, but it lands the element resets, base layer, shells and patterns on top of 4,600 lines that were written without them — a visual regression across every page in the app, delivered as a side effect of converting one dialog. This is phase 02's destination, not its first step.
  • Copy the .lk-confirm rules into apps/web/src/styles/components.css. Fastest, and the exact failure mode ADR-0003 and the hand-copied token file exist to forbid: a second source for one component's appearance, drifting from the first.
  • Slice a layer per component at build time. Rejected as a second build system. The namespace guarantee is what makes taking a layer safe, and it holds for the whole layer just as well as for a slice of it.
  • Leave the icon as a Phosphor class and add Phosphor to the app. A third-party icon font, loaded across the whole app, to draw two glyphs the component could draw itself — while the app already ships lucide-react.

Source: docs/decisions/0020-studio-ships-the-component-css-the-conversion-needs.md

Library