DESIGN SYSTEM V2
DESIGN SYSTEMS
A semantic layer built on top of shadcn. Component source remains unforked; everything expressive — brand, theme, density, dark mode, contrast — moves into a three-tier token pipeline, with an interface for tracing and overriding it. The semantic naming is the substantive part: generated interfaces require roles that can be reasoned about rather than hex values that have to be inferred.

Platform:
Web (React, Tailwind)
Year:
2026
Role:
Design & build
Stack:
shadcn · Base UI · Style Dictionary

Platform:
Web (React, Tailwind)
Year:
2026
Role:
Design & build
Stack:
shadcn · Base UI · Style Dictionary
Introduction
The problem: components without a semantic vocabulary
Copy-paste component libraries address only half of the problem. A project receives forty accessible, well-built components in its own repository, but they arrive full of hardcoded utility classes and raw variable names that carry no meaning outside the file they sit in. There is no answer to the question of what colour a destructive action is in a given brand, because the answer is written as bg-red-500 in nine separate places. Design System v2 adds a semantic layer above that: roles, weights and states with names, resolved through tokens, with the component source left exactly as it arrived.


  • Three token tiers — primitive, semantic, component — resolved by Style Dictionary in W3C DTCG format.
  • Four bridge layers so shadcn components pick up tokens without a single edit to their source.
  • 465 tokens, of which 213 are semantic colours: 10 roles × 7 weights, with 5 states on the interactive weights.
  • Dark mode as 213 redeclared semantic values under one attribute — no JavaScript involved.
  • A six-tab interface for tracing a component's token chain, editing semantics, and exporting overrides.
  • Spec-Driven
    Spec-first repository structure
    The repository is written spec-first. Four markdown documents hold the rules — the architecture and phase gates, the token specification, the bridge implementation, and the working agreement for anyone editing the repository — and the token values sit beside them as W3C DTCG JSON. Nothing downstream is authored twice. Style Dictionary resolves the JSON into CSS, a Tailwind preset and the bridge, with outputReferences enabled so that the var() chains survive into the output and the browser performs the final resolution at runtime. That is what makes dark mode a redeclaration rather than a rebuild, and it follows from the underlying principle: values are referenced, never copied.
    The spec sits on the left as markdown rules plus token JSON. Style Dictionary resolves it into CSS, a Tailwind preset and the bridge, and Storybook and the docs site consume those. Edges that resolve the spec by reference cannot drift; edges that restate its values by hand do — twenty of fifty-eight documented colour values had drifted when measured.THE SPEC · WRITTEN FIRSTRESOLVED AT BUILDWHAT THE TEAM SEESTHE RULESPLANNING_PROMPT · TOKEN_SPECSHADCN_INTEGRATION · CLAUDE.mdnaming, tiers, phase gatesTHE VALUESpackages/tokens/**/*.jsonW3C DTCG, $value + $type465 tokens, references not copiesSTYLE DICTIONARYusesDtcg · outputReferenceskeeps var() chains intact so thebrowser resolves them at runtimeTOKENS.CSS · DARK.CSS465 vars · 213 redeclared for darkPRESET.TS · BRIDGE CSSTailwind scales + shadcn var mappingSTORYBOOK47 stories · reads computed valuesDOCS SITE50 pages, builds cleanswatches read var() — labels do notRESOLVED BY REFERENCE · CANNOT DRIFTRESTATED BY HAND · DRIFTS SILENTLYMEASURED, NOT ASSUMEDEvery documented token name still exists in the build — 58 of 58. The swatches are correct too, because they read the livevariable. But 20 of the 58 printed hex labels no longer match: the palette moved from gray to stone and blue to sky, and thehand-typed values stayed behind. The bridge shows the same pattern in reverse — 7 variables ship that the spec never mentions.THE RULE: WHERE A CONSUMER REFERENCES THE SPEC IT STAYS TRUE. WHERE IT RETYPES THE SPEC IT ROTS.
    Fig. 01 — Spec as the source, and the one place it leaks. Audited against the repo, not taken on trust.
    Audit: what held, and what drifted
    The system was audited rather than assumed correct. Every one of the 58 colour tokens documented on the docs site still exists in the build, with no orphans and no dangling renames, and the swatches render correctly because they read the live custom property. The documentation site builds without errors across 50 pages. However, 20 of those 58 printed hex labels are incorrect. The neutral palette moved from gray to stone and the interactive role from blue to sky, and because those labels are typed into the MDX by hand rather than read from the token, they remained on the previous values. The bridge shows the same fault in the opposite direction: seven variables ship in the CSS that the specification does not mention.
    The conclusion is narrower than a general instruction to keep documentation in sync. Spec-driven development holds exactly as far as consumption is by reference. A swatch declaring background: var(--color-neutral-surface) resolves to the current value, whereas a caption stating #f9fafb is a copy and diverges as soon as the token changes. The remedy is structural rather than procedural: read the value at render time, or generate the page from the tokens.
    The existing enforcement mechanism
    One enforcement mechanism already exists in the repository, and it serves as a model for the rest. A Storybook story renders every Tailwind utility the components rely on — text-sm, rounded-lg, font-medium and the others — reads back the computed style, and marks each according to whether it resolved to a var() reference or to a raw pixel value. This makes the scale replacement verifiable rather than asserted. It covers the component layer. It does not cover the documentation layer, which is where the drift occurred.
    The Semantic Layer
    Semantic naming: roles rather than values
    A primitive token records gray-950. A semantic token records color-neutral-heavy, denoting darkest text and high-contrast labels. The first states a fact about a colour, the second states a decision about a role, and only the second survives a rebrand. Every semantic token references a primitive rather than restating its value, so the brand can be replaced underneath without modifying any component, and the chain remains inspectable end to end.
    Semantic roles and generative interfaces
    Semantic naming becomes more significant where interfaces are generated. If a model assembles an interface, or a component that does not yet exist has to be styled correctly on first render, it requires a vocabulary with meaning attached. An instruction expressed as critical, trim weight, hover state can be reasoned about and validated, whereas a hex value such as #dc2626 is correct in one theme and wrong in the other. Semantic roles give generation a target that can be checked, and give review a question that can be answered: whether the role is correct, rather than whether the colour is.
    Grid of ten semantic colour roles against seven weights, from surface through to heavy. The four middle weights carry five interaction states each, which is what takes the set to 213 colour tokens.ROLEWEIGHT · LIGHTEST TO DARKESTSURFACEBACKGROUNDSUBDUEDTRIMBASEMEDIUMHEAVYNEUTRAL×5×5×5×5INTERACTIVE×5×5×5×5SUCCESS×5×5×5×5WARNING×5×5×5×5CRITICAL×5×5×5×5INFO×5×5×5×5SECONDARY×5×5×5×5ACCENT-ONE×5×5×5×5ACCENT-TWO×5×5×5×5ACCENT-THREE×5×5×5×5×5 = default, hover, pressed, selected, disabled. Ten roles × seven weights, with five states on the four interactive weights.213 COLOUR TOKENS
    Fig. 02 — The semantic colour grid. A designer picks a role and a weight; the state variants come with it.
    Ten roles, seven weights, and five states on the four interactive weights. The resulting count is the argument for generating tokens rather than authoring them: 213 colour values exceeds the point at which consistency can be maintained by hand, and each value has to hold its contrast relationship in both themes.
    The Bridge
    The bridge: four layers, with component source unmodified
    The hard constraint was that shadcn component source is never modified. That keeps updates inexpensive, since a new version is a copy rather than a merge conflict, but it requires the tokens to reach the components from outside. Layer one maps shadcn's stable CSS variable names onto semantic tokens, which covers every colour in every component, including components not yet added. Layer two replaces Tailwind's default scales rather than extending them, so the utility classes already present in the source — text-sm, rounded-lg, font-medium — resolve to token variables at build time. Layer three adds role-named utilities for components shadcn does not ship. Layer four scopes per-component variables by data-slot, so a single component can be restyled without affecting the role it inherits from.
    Architecture diagram: shadcn component source on the left, unmodified; four bridge layers in the middle mapping shadcn variable names and Tailwind scales onto semantic tokens; and the three-tier token pipeline on the right running primitive to semantic to component.SHADCN SOURCE · NEVER EDITEDTHE BRIDGE · FOUR LAYERSTOKENS · THREE TIERSCOMPONENTclassName="bg-primary text-smrounded-lg px-4"39 components, copied in as-is01 · CSS VAR BRIDGE--primary: var(--color-interactive-base)--border: var(--color-neutral-trim)catches every colour, current and future02 · TAILWIND SCALE REPLACEMENTtheme, not theme.extend — so text-sm androunded-lg resolve to token vars instead ofTailwind’s hardcoded defaults03 · NAMED UTILITIEStext-body, p-md, rounded-inner —for components shadcn does not ship04 · COMPONENT BRIDGEper-component vars scoped by data-slot,so one component can be restyled withouttouching the role it inherits fromSEMANTIC285 role-named tokenscolor-interactive-basethe layer you design inPRIMITIVE180 raw valuesgray-50 … gray-950the layer you never nameCOMPONENToptional overridesreferencing semanticsDARK MODE213 semantic coloursredeclared under[data-theme="dark"] — zero JSREFERENCESRESULTA shadcn update is a copy-paste, not a merge conflict. New brand, new theme, new density — all of it happens in the token layer, and the component source never learns about it.
    Fig. 03 — The bridge. Four layers so that the component source stays vanilla and everything expressive lives in tokens.
    The distinction in layer two determines whether the approach works at all. Keys placed under Tailwind's theme replace its defaults; keys placed under theme.extend are added alongside them. Under extend, text-sm remains hardcoded at 0.875rem and the typography scale stays outside the token system.
    One component, traced. Button's --radius, --spacing-sm and --text-sm resolve through the bridge into semantic tokens and land on primitives; everything it does not touch is dimmed.
    Theming
    Theming through token overrides
    Because the semantic layer is the only interface the components see, applying a brand consists of overriding token values, rather than rewriting components or maintaining a parallel copy of the library. The primitive palette is replaced, the semantic references remain identical, and all forty components change simultaneously. Dark mode is the same operation at smaller scale: 213 semantic colour values redeclared under a data attribute, with the browser resolving the var() chain at runtime, without a theme provider and without a re-render.
    Semantics. Typography roles composed from primitives, each showing the primitive it references — change the reference, not the hundred places it is used.
    Accessibility
    Generating colour ramps
    A brand colour arrives as a single hex value and has to become an eleven-step ramp that meets its contrast obligations at every step, in both themes. Ramps selected by eye tend to appear even and measure poorly. These are generated with Chroma Sculptor, a separate tool, which builds the ramp in a perceptual colour space, reports the contrast of every step against both ends, and allows the chroma curve to be shaped against the gamut rather than estimated.
    Eleven steps generated in CIE L*a*b*, each reported in OKLCH with its WCAG contrast against white and black, AA and AAA labelled per step. APCA is available alongside WCAG.
    Contrast of each of the eleven neutral steps against white and against black, on a log scale, with the WCAG AA threshold of 4.5 and AAA threshold of 7 marked. The two curves cross between steps 500 and 600.CONTRAST RATIO PER STEPLOG SCALEAAA · 7.0AA · 4.5AA LARGE · 3.001002003004005006007008009001000AS TEXT ON WHITEAS TEXT ON BLACKCROSSOVER AT STEP 500
    Fig. 04 — Every step carries its contrast with it. Step 500 is the pivot: the last step that fails AA on white is the first that clears it on black, which is what makes a light/dark token pair mechanical rather than hand-tuned.
    Perceptual colour space and contrast thresholds
    Ramps produced by adjusting HSL values are perceptually uneven, because HSL lightness does not correspond to measured lightness. The same eleven steps generated on an even perceptual ramp read as evenly spaced in OKLCH and sag through the middle in HSL. That difference is the error a hand-tuned palette inherits, and it is why two brand colours with the same nominal lightness can fall on opposite sides of a contrast threshold.
    The same eleven steps read as OKLCH lightness and as HSL lightness. OKLCH tracks the even CIE L star ramp the scale was generated on; HSL sits consistently below it in the mid range.LIGHTNESS OF EACH STEP · 0–100GENERATED IN CIE L*a*b*025507510001002003004005006007008009001000OKLCH LIGHTNESSHSL LIGHTNESS11 STEPS · 0 TO 100
    Fig. 05 — Why the colour space matters. The ramp is even by construction; HSL reports it as uneven, and a palette tuned by HSL numbers inherits that error.
    The chroma curve, shaped against the gamut boundary rather than guessed — stops are dragged in lightness/chroma space, with the maximum available chroma at each lightness drawn behind them.
    The Interface
    The token map interface
    A token system that cannot be inspected becomes undocumented practice within a short period. The token map addresses this. Graph traces a component's full chain across four columns, Inspector reads a single node, Primitives and Semantics are editable views of the two token tiers, Preview renders components under the current values at three viewports, and Overrides toggles whole categories — border, spacing density, radius, shadow, sizing, motion, opacity, surface and z-index — then exports the result as JSON or CSS.
    Overrides. Toggle a category, watch every component respond, then export the delta as JSON or CSS — this is what a brand handover looks like when the system is token-driven.
    Preview, dark. The same components, the same component source — only the semantic values underneath have changed.
    Primitives. The raw layer nothing is designed against directly, kept visible so that the references resolve to a legible value.
    The Process
    Foundations: shadcn Base UI components generated unmodified into the workspace, Storybook as the verification environment
    Colour: Brand hues expanded into 11-step ramps in Chroma Sculptor, contrast checked per step against both themes
    Tokens: W3C DTCG JSON in three tiers, resolved by Style Dictionary with references preserved into the CSS output
    Bridge: CSS var mapping, Tailwind scale replacement, named utilities, per-component data-slot scoping
    Verification: A coverage story that fails if any component cell shows a raw pixel value instead of a var() reference
    Interface: Token map for tracing, editing and exporting overrides across six views
    Links