Full answer
A design system is a product with users (other developers), so it needs a clear structure and a release process.
Layers:
- Tokens. Named values for color, spacing, radius, typography and motion, stored in a neutral format (JSON, with a tool such as Style Dictionary) and output as CSS variables. Themes (light, dark, brand) swap token values, not component code.
- Primitives (headless). Components that provide behaviour and accessibility without styling: dialog, menu, tabs, combobox, tooltip. Writing keyboard handling and ARIA correctly is hard, so build on tested libraries (Radix UI, React Aria, Headless UI, Ark UI) or write hooks that return props to spread.
- Styled components. Buttons, inputs and cards that apply tokens, with variants as typed props (
variant,size,tone) mapped to class names or CSS variables (class-variance-authority or similar). Limit the variant matrix. - Patterns. Compositions such as form fields, data tables and page headers.
API design. Prefer composition (<Card><Card.Header/></Card>, children, slots) to long lists of boolean props. Forward refs and rest props (ref is a prop in React 19) so consumers can attach behaviour. Support the as or asChild pattern for links. Be strict with accessibility defaults (labels required in types where possible).
Delivery. A package in a monorepo, published with semantic versioning. Use changesets, codemods for breaking changes, tree-shakeable ESM output, a CSS strategy that avoids runtime cost (CSS variables, CSS modules, or zero-runtime CSS-in-JS), and a deprecation policy.
Quality. Storybook as catalogue and playground, interaction tests with play functions, axe checks, visual regression (Chromatic or similar), unit tests for logic, and visual and accessibility review in pull requests.
Governance. Contribution guidelines, an owner team, a roadmap driven by product needs, usage analytics (which components are used) and design tooling parity (Figma components match code).
Pitfalls: building too many variants early, leaking implementation details in props, no migration path, and styling overrides that break consistency.
The example shows a token-driven button with typed variants on top of a headless toggle hook.
import { useState } from 'react';
// Tokens: the single source of truth, usually generated and output as CSS variables.
const tokens = { color: { primary: '#0b5fff', neutral: '#444' }, space: { sm: '4px', md: '8px' } };
// Headless behaviour: state and accessibility props with no styling.
function useToggle(initial = false) {
const [pressed, setPressed] = useState(initial);
return { pressed, buttonProps: { 'aria-pressed': pressed, onClick: () => setPressed((p) => !p) } };
}
// Styled layer: variants are typed props mapped to tokens.
const variants = {
primary: { background: tokens.color.primary },
neutral: { background: tokens.color.neutral },
};
function ToggleButton({ variant = 'neutral', children }) {
const { buttonProps } = useToggle();
return (
<button {...buttonProps} style={{ ...variants[variant], padding: tokens.space.md, color: 'white' }}>
{children}
</button>
);
}
export default function App() {
return (
<div>
<ToggleButton variant="primary">Bold</ToggleButton>
<ToggleButton>Italic</ToggleButton>
</div>
);
}This sketch shows the layers in one file: tokens, a headless hook and a styled component. A real system splits them into packages. The check pressed both buttons. Rendered result: <div><button aria-pressed="true" style="background: rgb(11, 95, 255); padding: 8px; color: white;">Bold</button><button aria-pressed="true" style="background: rgb(68, 68, 68); padding: 8px; color: white;">Italic</button></div>
Key points
- Layer the system: tokens, headless primitives, styled components and patterns.
- Reuse tested headless libraries for accessible behaviour, and theme with CSS variables.
- Design small composable APIs with typed variants, forwarded refs and asChild or as.
- Ship as a versioned package with changesets, codemods and a deprecation policy.
- Test accessibility and visuals, document in Storybook, and govern with owners and usage data.
Common mistakes
- Building every component from scratch instead of using tested headless primitives.
- Exposing dozens of boolean props instead of composition.
- Shipping breaking changes with no codemod or deprecation period.
- Letting products override styles freely and losing consistency.
- Treating the design system as a one-time project without owners.
Follow-ups
- How would you theme the system with CSS variables and support dark mode?
- How do you version and communicate a breaking change?
- How do you measure adoption of the design system?
Tips
- Present the layers in order and name a tool for each.
- Mention governance and versioning. They are what makes it work at scale.
- Emphasize accessibility as a default.