Skip to content
NewTemplates & toolkits are on the way — join the waitlist
Hecham Gazhi

Design Systems · Lesson 12 / 13

From design to code

How a design system lives in code: the token pipeline, building a component library, matching APIs, theming, packaging and versioning, Storybook, visual and accessibility testing, and keeping Figma and code in sync.

4 min read · 5 quiz questions

Design and code: one system, two places

A design system that exists only in Figma is a UI kit. The real system lives in code too — in a component library that product teams install and use. The challenge is keeping both sides in sync so that what designers place in Figma is exactly what developers can build.

The goal is parity: the same tokens, the same components, the same names, the same options, the same states.

The token pipeline

  1. 1Source of truth — tokens are defined in one place: Figma variables, a tokens plugin, or JSON in a Git repository.
  2. 2Export — tokens are exported as JSON, ideally in the W3C Design Tokens format.
  3. 3Transform — a build tool like Style Dictionary converts JSON into platform formats.
  4. 4Distribute — outputs are published in a package that apps install.
  5. 5Consume — components and apps use token names, never raw values.
Exampletext
tokens/*.json  ──▶  Style Dictionary  ──▶  build/
                                           ├── css/variables.css     (--color-action-primary)
                                           ├── js/tokens.ts          (colorActionPrimary)
                                           ├── ios/Tokens.swift      (Color.actionPrimary)
                                           └── android/colors.xml    (@color/action_primary)

Building the component library

  • Pick the frameworks your products use (e.g. React for web, SwiftUI for iOS, Jetpack Compose for Android). Many systems also offer Web Components to work across frameworks.
  • Build components on accessible foundations — native elements, or proven headless libraries (such as Radix UI, React Aria or Headless UI) that handle keyboard and ARIA behaviour.
  • Style components only with tokens.
  • Support theming through CSS variables or a theme provider.
  • Support RTL with logical properties.
  • Make components composable and forward refs and native attributes so teams aren't blocked.

Matching component APIs

Figma properties and code props should be a direct translation:

Figma propertyCode prop
Variant = Primary / Secondary / Dangervariant="primary" | "secondary" | "danger"
Size = SM / MD / LGsize="sm" | "md" | "lg"
Show icon = true (boolean)iconStart={<Icon />}
Label = "Continue" (text)children="Continue"
State = Disableddisabled
State = Hover / Focus / PressedHandled by CSS (:hover, :focus-visible, :active) — not props
Exampletsx
import { Button } from "@acme/design-system";
import { ArrowRight } from "@acme/icons";

export function CheckoutFooter() {
  return (
    <Button variant="primary" size="md" iconEnd={<ArrowRight />}>
      Continue to payment
    </Button>
  );
}

Interaction states like hover and focus are designed in Figma as variants, but in code they're usually CSS states, not props. Document this so designers don't expect a state prop.

Packaging and versioning

  • Publish the library as a package (e.g. on npm, or a private registry) so products install a specific version.
  • Use semantic versioning: MAJOR for breaking changes, MINOR for new features, PATCH for fixes.
  • Write a changelog for every release, with migration notes for breaking changes.
  • Consider codemods — scripts that automatically update product code for breaking API changes.
  • Release regularly and predictably so teams can plan upgrades.

Documenting and testing in code

PracticeWhat it does
Storybook storiesEvery component, variant and state rendered in isolation; interactive props
Visual regression testsScreenshots compared on each change to catch unintended visual changes (e.g. Chromatic, Playwright snapshots)
Accessibility testsAutomated axe checks in stories and unit tests; manual keyboard and screen reader checks
Unit / interaction testsBehaviour: clicking, typing, keyboard navigation, focus management
Type checkingTypeScript types document the API and prevent invalid props

Keeping Figma and code in sync

  • Use the same names for tokens, components and properties in both places.
  • Automate token sync so values can't drift.
  • Use Figma Dev Mode and Code Connect (where available) so inspecting a component in Figma shows the real code snippet.
  • Include designers and developers in each other's reviews: a component is "done" only when it exists, matches, and is documented on both sides.
  • Track parity in a simple table: component, Figma status, code status, docs status.
ComponentFigmaCodeDocs
ButtonStableStableComplete
Text fieldStableStableComplete
Date pickerBetaIn progressDraft
Data tablePlanned——

Common mistake: Designers creating new variants in Figma that don't exist in code. Product designers use them, developers can't find them, and they build one-offs. New variants should be proposed, built and released together.

Key takeaways

  • A real design system lives in both design and code, with parity between them.
  • Tokens flow from one source of truth through tools like Style Dictionary to every platform.
  • Build accessible, token-styled, themeable components with APIs that mirror Figma properties.
  • Package with semantic versioning, changelogs and migration notes.
  • Test visually, for accessibility and for behaviour, and keep Figma and code in sync on purpose.

Exercise

Mirror a component in code

  1. Take the Button you built in Figma.
  2. Write its props as a TypeScript type that mirrors the Figma properties.
  3. Implement it with CSS variables from your tokens (any framework, or plain HTML/CSS).
  4. Add hover, focus-visible, active, disabled and loading styles.
  5. Fill in a parity table comparing the Figma and code versions.

Test yourself

From design to code quiz

5 questions. Score 70% or more to complete the lesson.

  1. 1.What does 'parity' mean between design and code?
  2. 2.What does a tool like Style Dictionary do?
  3. 3.Renaming a component prop is which kind of release?
  4. 4.In code, hover and focus states are usually…
  5. 5.What do visual regression tests catch?