Insights

Component Libraries: Figma to Production Pipeline

Anya Petrov
Apr 24, 20269 min read
Component Libraries: Figma to Production Pipeline

The Reference Artifact: A Real Design Tokens JSON

The artifact below represents a complete tokens file exported from Figma using the Tokens Studio plugin, then transformed via Style Dictionary into platform-agnostic values. This isn't a simplified tutorial example—it's the actual structure AR-COORP uses for client projects where design system adoption exceeds eighty-seven percent of production screens. Every token name follows a three-tier hierarchy: category, variant, and state. The naming convention eliminates ambiguity during first round reviews and ensures that engineers can match Figma layers to CSS custom properties without asking clarifying questions.

{
  "color": {
    "brand": {
      "primary": { "value": "#6366f1" },
      "secondary": { "value": "#818cf8" },
      "accent": { "value": "#f59e0b" }
    },
    "neutral": {
      "50": { "value": "#f8fafc" },
      "900": { "value": "#0f172a" }
    },
    "semantic": {
      "success": { "value": "{color.green.600}" },
      "error": { "value": "{color.red.600}" }
    }
  },
  "typography": {
    "scale": {
      "xs": { "value": "0.75rem" },
      "base": { "value": "1rem" },
      "2xl": { "value": "1.5rem" }
    },
    "weight": {
      "regular": { "value": "400" },
      "semibold": { "value": "600" }
    },
    "leading": {
      "tight": { "value": "1.25" },
      "relaxed": { "value": "1.75" }
    }
  },
  "spacing": {
    "0": { "value": "0" },
    "1": { "value": "0.25rem" },
    "4": { "value": "1rem" },
    "16": { "value": "4rem" }
  }
}

This structure leverages JSON references—notice how semantic.success points to color.green.600 rather than hardcoding a hex value. When the brand palette shifts, semantic tokens update automatically. The architecture prevents the common failure mode where a designer updates primary blue in Figma but the codebase still references the old value three sprints later. Aliasing tokens to other tokens creates a dependency graph that Style Dictionary resolves during build time, outputting format-specific files for CSS, SCSS, JavaScript, and iOS Swift.

Figma Variables Configuration That Survives Handoff

Figma's native variables feature replaced the need for third-party plugins in mid-2023, but most teams configure variables incorrectly—treating them as isolated design-time helpers rather than the canonical source. The correct approach: map every variable to a corresponding token name that matches your front-end naming convention exactly. When a Figma variable is named color/brand/primary with slashes as delimiters, the exported JSON maintains that hierarchy without transformation. Engineers then import those values directly into CSS custom properties with zero renaming friction.

The variable scoping decision determines whether your design system scales or collapses under its own weight. Primitive collections contain raw values—exact hex codes, unitless line-height ratios, base pixel spacing. Semantic collections reference primitives and assign intent: surface-primary might resolve to neutral.50 in light mode and neutral.900 in dark mode. This two-tier strategy prevents the proliferation of one-off values that dilute the system. Every new component pulls from semantic tokens, and semantic tokens pull from a controlled primitive set, keeping the total token count manageable even as the component library grows past two hundred elements.

Style Dictionary Transformation Pipeline Architecture

Style Dictionary is an unopinionated build system that transforms design tokens into platform-specific formats through a configuration file. The pipeline runs as a pre-commit hook or CI step—not a manual export task. When a designer updates Figma variables and exports the JSON, the next Git push triggers Style Dictionary to generate updated CSS custom properties, SCSS maps, JavaScript modules, and Swift constants. The entire design-to-code loop completes in under four seconds, maintaining parity without human translation errors.

A design system without automated token deployment is just a static artifact that decays with every sprint.

The configuration file defines transforms that convert token names into idiomatic patterns for each platform. CSS custom properties receive kebab-case names prefixed with --, while JavaScript exports use camelCase. SCSS outputs include both variables and map structures for iteration. The transformation layer also handles unit conversion: Figma records spacing in pixels, but the output generates rem values with a configurable base. This prevents the common problem where designers specify sixteen-pixel padding but the codebase uses a different root font size, breaking the spacing rhythm. Style Dictionary applies math transforms during build time, so the exported values always match the designer's intent regardless of platform conventions.

Component Mapping Strategy Between Figma and Code

The hardest part of maintaining a component library isn't the initial build—it's keeping Figma components synchronized with their front-end counterparts as both evolve. The strategy that works: establish a bidirectional naming contract where every Figma component has a matching code component with identical props, states, and variants. A Figma button component named Button/Primary/Default maps to a React component

Service
Service

Stay in the loop

Case studies, playbooks and short essays on shipping software well. No spam, zero filler.

💭
LinkedInTwitterFacebook