Skip to main content
03

Design a design system for several product teams

MediumDesign systemDesign tokensThemingComponent API

Design a design system (a shared component library) used by several product teams: what goes into it, how it's built, how teams consume it, and how it evolves without breaking them.

A typical framing: "We have five product teams building different apps, and every team has its own buttons, colors and modals. Products look inconsistent and we keep rebuilding the same components. You're the first engineer on the new design system team. What do you build, and how?"

TL;DR

A design system is more than a component library. It has layers: design tokens (colors, spacing, typography as named variables), foundations (accessibility rules, layout, icons), components with a stable API, and documentation with guidelines. Tokens are the source of truth, are generated for every platform, and make theming (dark mode, brands) a matter of swapping values. Components are accessible by default, built in layers (headless behavior plus styles), and expose composable APIs rather than dozens of props. The library ships as a versioned package with semantic versioning, changelogs and codemods, is tested with visual regression and accessibility tests, and is documented in Storybook. Success is measured by adoption, and the team treats product teams as customers.

1. Requirements

Questions worth asking:

  • How many teams and apps? Which frameworks? (All React, or also Angular, mobile, server-rendered pages?)
  • Is there a design team and a design tool (Figma) to stay in sync with?
  • Do we need multiple themes or brands? Dark mode? RTL (Hebrew and Arabic)?
  • What's more painful today: inconsistency, development speed, or accessibility?

Functional

  • Tokens: color, typography, spacing, radius, shadow, motion, breakpoints.
  • Core components: Button, Input, Select, Checkbox, Modal/Dialog, Tooltip, Tabs, Toast, Table, and layout primitives (Stack, Grid).
  • Theming (light/dark, brands) and RTL support.
  • Docs with live examples and usage guidelines.

Non-functional

  • Accessibility: WCAG 2.2 AA out of the box.
  • Stability: teams can upgrade safely. Breaking changes are rare, announced and automated.
  • Performance: tree-shakable, small bundles, no runtime CSS cost where possible, works with SSR.
  • Adoption: easier to use than building your own, or teams won't use it.

2. Architecture

Loading diagram...

Layers

  1. Design tokens: platform-neutral values in JSON, exported from the design tool. A build step (e.g. Style Dictionary) generates CSS custom properties, TypeScript constants and native values. Tokens have tiers:

    • Primitive: the raw palette, blue-500: #2563eb.
    • Semantic: the meaning, color-action-primary: {blue-500}, color-text-muted.
    • Component (optional): button-primary-bg: {color-action-primary}.

    Components only use semantic tokens. Then a theme or a brand only remaps semantic tokens to other primitives, and no component changes.

  2. Headless behavior: focus management, keyboard interaction and ARIA wiring. Building this correctly is the hardest part, so it's common to build on proven primitives (Radix, React Aria, Ark UI) rather than from scratch.

  3. Styled components: behavior plus token-based styles.

  4. Patterns and templates: compositions like a form layout, an empty state or a settings page, documented as recipes.

3. Data model

The "data" of a design system is tokens and component APIs.

json
{
  "color": {
    "blue": { "500": { "$value": "#2563eb", "$type": "color" } },
    "action": {
      "primary": { "$value": "{color.blue.500}", "$type": "color" }
    }
  },
  "space": { "2": { "$value": "8px", "$type": "dimension" } }
}

Generated output:

css
:root {
  --color-action-primary: #2563eb;
  --space-2: 8px;
}
[data-theme='dark'] {
  --color-action-primary: #60a5fa;
}

Because themes are just CSS variables, switching dark mode is one attribute on <html>, with no re-render and no flash, as long as the attribute is set before first paint.

4. Interface (API)

Component API principles

  • Small, predictable props with variants as enums: variant="primary" | "secondary" | "ghost", size="sm" | "md" | "lg".
  • Composition over configuration: instead of a <Modal title footer showClose onConfirm ...> with 30 props, compose parts:
tsx
<Dialog>
  <Dialog.Trigger asChild>
    <Button>Delete</Button>
  </Dialog.Trigger>
  <Dialog.Content>
    <Dialog.Title>Delete project?</Dialog.Title>
    <Dialog.Description>This can't be undone.</Dialog.Description>
    <Dialog.Close asChild>
      <Button variant="ghost">Cancel</Button>
    </Dialog.Close>
  </Dialog.Content>
</Dialog>
  • Extend the native element: forward ref, spread the rest of the props, accept className. A Button should accept everything a <button> does.
  • Polymorphism (asChild or as) so a Button can render a router Link without losing its styles.
  • Controlled and uncontrolled modes for stateful components (value + onChange, or defaultValue).
  • Escape hatches exist but are visible in code review, so teams don't fork components quietly.

Distribution

  • One package (@acme/ui) or a few (@acme/tokens, @acme/ui, @acme/icons), built as ESM with per-component entry points so bundlers tree-shake unused components.
  • Semantic versioning: patch for fixes, minor for new components or props, major for breaking changes. Automate releases and changelogs with Changesets.
  • Codemods for breaking changes, so upgrades are one command.

5. Optimizations and deep dives

Styling strategy

ApproachProsCons
CSS Modules / plain CSS with variablesNo runtime, SSR-friendly, framework-agnosticLess dynamic, manual class composition
Utility CSS (Tailwind) with tokens in the configFast to build, consistent, small CSSConsumers need the same setup, class-heavy markup
Runtime CSS-in-JS (styled-components)Dynamic styles, co-locatedRuntime cost, problems with Server Components and streaming
Zero-runtime CSS-in-JS (vanilla-extract, Panda)Typed, no runtimeBuild-time setup

Today, the safer default is CSS variables for tokens plus a zero-runtime approach. Runtime CSS-in-JS is falling out of favor because of its cost and its poor fit with React Server Components.

Accessibility by default

The biggest value a design system gives is that every team gets correct focus traps, keyboard navigation, ARIA and contrast without thinking about it. Bake it in:

  • Token contrast pairs checked in CI.
  • axe checks in component tests, plus manual screen reader testing for complex widgets.
  • Visible focus styles that can't be turned off by accident.
  • RTL support with logical CSS properties (margin-inline-start, not margin-left), and icons that flip direction when they mean "forward" or "back".

Quality and testing

  • Unit and interaction tests (Testing Library) for behavior and keyboard support.
  • Visual regression tests (Chromatic, Playwright screenshots) on every story, in every theme, to catch unintended visual changes.
  • Storybook as the workshop and the docs: every component has stories for its variants and states, with usage guidelines ("when to use a Dialog vs. a Drawer").

Adoption and governance

  • Treat product teams as customers: office hours, a Slack channel, a public roadmap.
  • Contribution model: teams can propose and contribute components. The core team reviews them for API consistency and accessibility.
  • Measure adoption: scan repositories for imports of the system vs. local duplicates, and track the versions in use.
  • Migrate incrementally. New screens use the system first, and old screens are migrated with codemods. Never a big-bang rewrite.

Common follow-ups

  • "How do you support a second brand with a different look?" Same components, a second set of semantic token values, switched with a data-brand attribute or a separate CSS file.
  • "A team needs a variant you don't have. What do they do?" Compose from existing parts first. If it's a real repeated need, it goes through the contribution process. As a last resort, use an escape hatch, which is tracked as tech debt.
  • "How do you avoid breaking 20 apps with one release?" Semver, deprecation warnings a version ahead, visual tests, codemods, and canary releases tested in a few apps first.
  • "Monorepo or separate repo?" A monorepo with the apps makes cross-cutting changes and testing easier. A separate repo with published versions gives teams control over when they upgrade. Both work; the versioning discipline is what matters.

What interviewers look for

  • Seeing the system as tokens + components + docs + process, not only a folder of React components.
  • Token tiers (primitive vs. semantic) and how theming falls out of them.
  • Composable component APIs and awareness of the "prop explosion" problem.
  • Accessibility and RTL as built-in features.
  • Versioning, testing and adoption: how the system evolves without breaking its consumers.

Was this helpful?