What You'll Learn
- 1Layer tokens from raw values to semantic roles so theming works without component changes
- 2Design component APIs that resist configuration sprawl and stay composable
- 3Turn accessibility requirements into automated tests rather than review comments
- 4Ship breaking changes with deprecation warnings that let consumers migrate gradually
A design system is a product with two audiences: the designers who set the rules and the engineers who have to ship under deadline while following them. Systems fail in a predictable way. The first version is beautiful, adoption stalls because the components cannot express the one case a feature needs, teams fork their own button, and a year later there are four button implementations and a system that everyone agrees is the standard. The work that prevents this is unglamorous â naming, API restraint, tests, documentation and a deprecation policy â and it matters more than the visual design, which can be restyled from tokens in an afternoon if the structure underneath is sound.
Tokens are a layered language
A token that stores a colour is a missed opportunity. The useful structure has three layers: raw values that record what exists, semantic tokens that express intent, and component tokens that expose the few knobs a specific component may turn. A component that references brand primary rather than a hex value can be rethemed by changing one file, and a dark mode becomes a second set of values rather than a sweep of overrides.
// tokens.js â raw, semantic, component layers
export const raw = {
color: {
blue600: '#2563eb',
slate900: '#0f172a',
slate50: '#f8fafc',
red600: '#dc2626',
},
space: { 1: '4px', 2: '8px', 3: '12px', 4: '16px', 6: '24px' },
radius: { sm: '4px', md: '8px', lg: '16px' },
};
export const semantic = {
color: {
accent: raw.color.blue600,
surface: raw.color.slate50,
textDefault: raw.color.slate900,
feedbackDanger: raw.color.red600,
},
};
export const themes = {
light: { ...semantic },
dark: {
color: {
accent: '#60a5fa',
surface: '#0f172a',
textDefault: '#f8fafc',
feedbackDanger: '#f87171',
},
},
};
export const component = {
buttonPrimary: {
background: 'var(--color-accent)',
foreground: '#ffffff',
paddingY: 'var(--space-2)',
paddingX: 'var(--space-4)',
radius: 'var(--radius-md)',
},
};
The indirection is the point. Feature code references semantic names, component code references component tokens, and only the token file knows actual values. Naming conventions that hold up are intent-based rather than visual: feedback danger rather than red, surface rather than grey two. Visual names break the moment a brand refresh changes the palette, while intent names survive it, and they force the conversation about what a colour is for rather than what it looks like.
Component APIs that do not sprawl
Every prop you add is a permanent commitment, because removing it breaks consumers. The discipline is to add a prop only when the variation is real, widespread and stable â three product teams asking for it, not one â and to prefer composition for everything else. A configuration prop multiplies combinatorially: a component with four boolean props has sixteen rendered states, most of which nobody designed and some of which are broken.
| Decision | Prefer | Reach for the alternative when |
|---|---|---|
| Variation of appearance | Variant and size enums | The brand needs many visual modes |
| Variation of structure | Children and slots | The layout is fixed everywhere |
| Behaviour | Callback props | The component owns the behaviour |
| Density or spacing | A scale token | Only one screen differs |
| Entirely different widget | Separate components | Shared code is only the wrapper |
Enforce the enums in types rather than in documentation, so an invalid value fails the build. Keep prop names parallel across components â if one component uses onSelect, they all do â because inconsistency at this level is what makes a system feel harder than the thing it replaced. And resist the convenience prop that exposes an internal element for styling; once consumers style the internals, the internals become public API and the component can never be refactored.
Composition beats configuration
The components that age well are the ones that let consumers assemble rather than configure. Compound components expose parts that share state internally, so a disclosure panel and its content stay in sync without the consumer wiring anything, and the same pattern scales to tables, menus and date pickers where a flat prop list would be unreadable.
import { createContext, useContext, useState } from 'react';
const DisclosureContext = createContext(null);
export function Disclosure({ defaultOpen = false, children }) {
const [open, setOpen] = useState(defaultOpen);
return (
<DisclosureContext.Provider value={{ open, setOpen }}>
<div className="disclosure">{children}</div>
</DisclosureContext.Provider>
);
}
export function DisclosureTrigger({ children }) {
const { open, setOpen } = useContext(DisclosureContext);
return (
<button
type="button"
aria-expanded={open}
aria-controls="disclosure-panel"
onClick={() => setOpen((value) => !value)}
>
{children}
</button>
);
}
export function DisclosurePanel({ children }) {
const { open } = useContext(DisclosureContext);
if (!open) return null;
return (
<div id="disclosure-panel" role="region">
{children}
</div>
);
}
The consumer writes markup that reads like the design, the system owns the aria wiring and the open state, and neither side has to know the other's conventions. Composition also keeps bundle size honest: consumers import only the parts they render, and a future implementation change inside one part does not touch their code.
Accessibility is a test, not a review step
Accessibility reviews happen too late and are easy to defer. The alternative is to encode the requirements where they cannot be skipped: a keyboard test that tabs through every interactive component and asserts focus lands where it should, a role and name check on every rendered variant, and a contrast assertion against the tokens so a palette change that breaks legibility fails the build. Storybook has plugins for exactly these checks, and running them per story means a new variant is covered the day it is written rather than the day before an audit.
Some properties cannot be automated and need a small manual checklist per component: does it behave correctly at two hundred per cent zoom, does it announce state changes, does it work with reduced motion, and what does it look like with the longest string your locale produces. Keeping that checklist inside the component's documentation makes it part of writing the component instead of a separate chore.
Documentation that cannot drift
Documentation rots when it is written as prose separate from the code. The version that survives is generated from the source: controls built from the type definitions, live examples that render the real component, and a usage section written next to the implementation so it is reviewed in the same pull request. A story that does not render is a failing test, which is a much more effective maintenance signal than a broken wiki page nobody owns.
Include the decision record alongside the examples. Why does this component not accept an onClick on the panel, why is the size prop an enum, why is the table not virtualised by default. Those answers are what stop the next engineer from opening a pull request that reintroduces the problem the decision solved, and they are the parts of documentation that get read during an argument.
Shipping changes without breaking consumers
Semantic versioning only works if the team means it. A breaking change to a component API requires a major version, a codemod where one is possible, and a deprecation window in which the old prop still works and logs a warning naming the replacement. Codemods turn a migration that nobody schedules into a single command, and they are disproportionately effective: teams that ship them see migrations complete in days rather than never.
Publish a changelog organised by component rather than by version, because consumers look up what happened to the button they use, not what happened in the release. Keep a migration guide for each major version with before-and-after snippets, and consider a compatibility layer that maps old props onto new ones for one release so the upgrade is a dependency bump rather than an afternoon of edits.
Knowing whether it works
Adoption is the only metric that matters, and it is measurable: the percentage of production components imported from the system, the number of divergent local implementations of the same pattern, and the time from a designer shipping a new pattern to an engineer having a component for it. Pair that with contribution flow â how many pull requests came from teams outside the core group â because a system only core contributors can extend will be bypassed the moment a deadline is tight.
Watch the support surface too. If the same question appears three times, the API or the documentation is wrong, and fixing it once removes it from the queue permanently. The system that stays adopted is the one that makes the correct thing the easiest thing, and that is a continuous job rather than a launch.
Common Mistakes
Naming tokens after colours so a rebrand rewrites every reference
Fix: Name tokens by intent such as accent or feedback danger
Adding boolean props until the component renders states nobody designed
Fix: Prefer composition and accept a new variant only after repeated real demand
Relying on manual accessibility review before release
Fix: Encode keyboard, role, name and contrast checks in automated story tests
Shipping breaking changes with a changelog entry and no deprecation path
Fix: Warn at runtime, provide a codemod, and keep the old API for a full release
Best Practices
- Keep raw, semantic and component token layers with only the last referencing CSS variables
- Enforce prop parallelism across components so the system feels learnable
- Expose compound parts so consumers assemble instead of configuring
- Generate documentation from source so a story that does not render fails CI
- Publish a migration guide and codemod with every major version
Key Takeaways
- Design systems fail on API discipline and migration policy, not on visual design
- Semantic tokens are what make theming and rebrands a one-file change
- Composition scales where configuration sprawls into unusable prop lists
- Automated accessibility tests keep requirements from being deferred to review
- Adoption and external contributions are the metrics that show a system is working