FreePixels Figma UI kit 路 components, tokens and themes, ready to duplicateGet it free
Figma8 min read

How to Build a Figma Design System That Matches Your React Code

How to build a Figma design system that matches your React component library: shared design tokens, matching props, Storybook and Figma Code Connect, in 8 steps.

Pixels team 路 Updated

Quick answer: A Figma design system matches your React code when three things are true. Both sides read the same design tokens. Every Figma component property has a React prop with the same name and options. And a build step, not a person, carries changes from Figma to code. Get those right and "the design says 12px, the code says 8px" stops being a weekly conversation.

This guide walks through the eight steps we use for Pixels, a free Figma UI kit and a React component library (@pixelsds/react on npm) built from the same source, with real screenshots and code from both sides.

Why do Figma designs and React code drift apart?

Most design systems start in sync and drift within months. The causes are almost always the same three:

  • Values copied by hand. A designer changes a radius in Figma and nobody updates the CSS. Every copy is a future mismatch.
  • Different names for the same thing. Figma calls it "Hierarchy: Tertiary brand", code calls it variant="link". People translate in their heads and get it wrong.
  • States that only exist on one side. Figma shows a pressed state nobody built, or code has a loading state nobody designed.

Each step below removes one of these causes.

One source of truth in four steps: Figma variables, a tokens file, CSS variables, React components How Pixels keeps Figma and React in sync: Figma variables become a tokens file, then CSS variables, then React components used by Storybook, the npm package and your app.

Step 1: Put every foundation in Figma variables

Colours, spacing, radius, type sizes and shadows go into Figma variables before you draw a single component. Components then bind to variables, never to raw values.

Use three tiers (primitive, semantic and component tokens) and modes for anything that changes as a set: Light and Dark, brand, density, screen size, language. Pixels has 942 variables in 7 collections; a starting system can have far fewer. Our design tokens guide covers the tiers and naming in detail.

Step 2: Give each component the same API in Figma and React

This is the step most teams skip, and the one that matters most. Every Figma component property should have a React prop with the same name and the same options.

The Pixels Button component set in Figma The Pixels Button component set in Figma: five variants, three sizes and five states, plus an RTL example where the arrow flips for Arabic.

Here is how the Pixels Button lines up:

Figma property Figma options React prop React values
Variant Primary, Secondary, Ghost, Tertiary, Danger variant primary, secondary, ghost, tertiary, danger
Size md 40 路 sm 36 路 xs 32 size md, sm, xs
Label Text children Any text
Icon start / Icon end Instance swap leadingIcon / trailingIcon An icon component
State Default, Hover, Pressed, Focused, Disabled isDisabled Hover, pressed and focus come from the browser

And the React side reads exactly like the Figma panel:

import { Button } from '@pixelsds/react';
import { ArrowRight, Trash } from '@pixelsds/react/icons';

export default function Actions() {
  return (
    <div className="flex gap-3">
      <Button trailingIcon={ArrowRight}>Get started</Button>
      <Button variant="secondary" size="sm">Cancel</Button>
      <Button variant="danger" leadingIcon={Trash}>Delete</Button>
    </div>
  );
}

A developer who has never opened the Figma file can read a design spec, and a designer can read a pull request. You can try this exact code by installing the package with npm install @pixelsds/react.

Step 3: Design every state, then let code own them

Figma needs a variant for every state so designers can show and review it. Code should not take those states as props, because the browser already knows when a button is hovered, pressed or focused.

The Pixels React components are built on React Aria, which reports these states as data attributes. Styles then read state tokens:

// Hover and press read their own tokens; no "state" prop needed
'bg-brand data-[hovered]:bg-brand-hover data-[pressed]:bg-brand-press'

Rule of thumb: if the user causes a state (hover, press, focus), it lives in CSS. If the app decides it (disabled, loading, selected), it is a prop.

Step 4: Turn Figma variables into code with a build step

Never copy a value from Figma to code by hand. Export the variables to a tokens file, and let a script write CSS custom properties from it:

--px-color-background-brand-default: var(--px-color-brand-500);
--px-button-primary-background-default: var(--px-color-background-brand-default);
--px-button-md-radius: var(--px-radius-12);

React components then use those variables and nothing else. When a designer changes button/md/radius in Figma, the next build changes every button in every app. If your team prefers a standard format, the W3C design tokens specification reached its first stable version in October 2025, and tools like Style Dictionary read it.

Step 5: Make Storybook the React side of the Figma file

Storybook is where developers, designers and product managers see the real components. Treat it as the coded twin of your Figma file: the same groups, the same names, every variant and every state, with copy-paste code.

The Pixels Storybook showing the Button in light, dark, RTL and a pink brand colour Watch the demo on the original post: the Button preview and its React code, then the same buttons in Arabic right to left, dark mode and a pink brand colour, all from tokens.

Three things make a Storybook design system genuinely useful in reviews:

  1. A live theme switch. Light, Dark, brand colours and density in the toolbar, so a designer can check a theme without asking for a build.
  2. An RTL switch on every preview. Mirroring bugs are cheap to fix in Storybook and expensive in production.
  3. The exact import line. If the code panel shows import { Button } from '@pixelsds/react', nobody copies a component file into their app by mistake.

Step 6: Connect Figma to code with Figma Code Connect

Figma Code Connect shows real code from your component library in Dev Mode when a developer selects an instance. Instead of generated CSS, they see the React component with the right props already filled in.

A Code Connect template maps each Figma property to a prop:

import figma from 'figma';
const instance = figma.selectedInstance;

const label = instance.getString('Label');
const variant = instance.getEnum('Variant', {
  Primary: 'primary', Secondary: 'secondary', Ghost: 'ghost', Tertiary: 'tertiary', Danger: 'danger',
});
const size = instance.getEnum('Size', { md: 'md', sm: 'sm', xs: 'xs' });

export default {
  example: figma.code`<Button variant="${variant}" size="${size}">${label}</Button>`,
  imports: ['import { Button } from "@pixelsds/react"'],
  id: 'button',
};

Because Step 2 already gave Figma and React the same names, these templates are short and almost write themselves. Pixels generates them from its component manifest.

Step 7: Build accessibility and RTL in from day one

Retrofitting either one means touching every component, so do both before the library grows.

  • Accessibility. Start from accessible primitives (React Aria, Radix or similar) for focus, keyboard and screen readers. Check text contrast on your colour tokens, not on individual screens. The Pixels palette shows an APCA score on every swatch.
  • Right to left. Use logical CSS properties (margin-inline-start, not margin-left) in every component, and add a Locale mode in Figma that switches the font for Arabic or Hebrew. Icons that point somewhere, like arrows, must flip. Icons that are objects, like a trash can, must not.

Step 8: Version Figma and React together

A design system is a product with two front doors. Release them together:

  • One version number. When the Figma library publishes v1.2, the npm package should be v1.2 too.
  • One changelog. List what changed for designers and for developers side by side.
  • Deprecate before you delete. Keep the old component for a release, mark it in both Figma and the docs, then remove it.

Checklist: is your Figma design system in sync with React?

  • Every value in a component is bound to a Figma variable
  • Figma properties and React props have the same names and options
  • Hover, press and focus are styled from tokens, not passed as props
  • A build step turns Figma variables into CSS variables
  • Storybook mirrors the Figma file, with theme and RTL switches
  • Code Connect shows real React code in Dev Mode
  • Figma library and npm package share one version and one changelog

Frequently asked questions

What is the difference between a Figma UI kit and a design system?

A UI kit is a set of drawn components. A design system adds the rules, tokens, code and documentation that keep those components consistent in production. A Figma design system with a matching React component library is a design system; a Figma file on its own is a kit.

How do I convert a Figma design system to React?

Export your Figma variables to a tokens file, generate CSS variables from it in your build, then build React components whose props match the Figma component properties one to one. Add Figma Code Connect so Dev Mode shows the real React code for each component.

What is Figma Code Connect?

Figma Code Connect is a Figma feature that shows real code from your component library in Dev Mode. When a developer selects a component instance, they see the matching React component with the right props, instead of auto-generated CSS.

Do I need Storybook if I have Figma?

Yes, if developers use the components. Figma shows what a component should look like; Storybook shows what it actually does, with real states, real data and real code.

Should Figma or code be the source of truth?

For tokens, Figma variables work well as the source, because designers change them most. For behaviour, code is the source. The build step in Step 4 and Code Connect in Step 6 keep the two honest.

How long does it take to build a design system in Figma and React?

A small set of foundations and ten core components can take a few weeks for a small team. A full system with themes, RTL and a few hundred components is months of work, which is why many teams start from an existing kit and customise its tokens.

Is there a free Figma design system with matching React components?

Yes. Pixels offers a free Figma UI kit and free React components that share the same tokens and component names. The links are below.

Free resources: start from a synced Figma and React kit

Want to skip the setup? Pixels follows every step above, and the starter versions are free:

Keep reading

Free to start 路 Pro when you ship

Start building with Pixels

Figma components, React code and design tokens that stay in sync. Every chart, pattern and template in Pro.