Terminal.skills
Use Cases/Convert Figma Designs to Production Code with AI

Convert Figma Designs to Production Code with AI

Turn Figma mockups into responsive, accessible React components using an AI agent that extracts design tokens and generates production-ready code.

Design#figma#frontend#design-to-code#react#css
Works with:claude-codeopenai-codexgemini-clicursor
$

The Problem

The handoff from design to code is where velocity dies. A designer delivers pixel-perfect Figma mockups, then a frontend developer spends days manually translating them — eyeballing spacing from the inspector panel, guessing how components should behave at different breakpoints, and copy-pasting hex colors that may or may not match the Tailwind config.

The result is predictable: inconsistent implementations, endless rounds of "can you move this 2px left" feedback, and designers who lose trust in engineering's ability to match their vision. A single page with 5-6 components easily burns 2-3 days of frontend work. And that is just the first pass — the review cycle adds another day or two of back-and-forth.

Meanwhile, the design system exists in Figma but not in code. Tokens for spacing, color, and typography are defined in the design file but have to be manually extracted and mapped to CSS variables or Tailwind classes every single time. The designer specifies Inter 18/28 regular #64748B and the developer has to figure out that maps to text-lg leading-7 text-slate-500 in Tailwind. Multiply that translation by every element on the page, and the tedium adds up fast.

The Solution

Using the figma-to-code and frontend-design skills, the agent extracts layout structure, design tokens, and component hierarchy directly from Figma designs, then generates responsive, accessible React components that match the mockup. The full page goes from Figma to working code in under an hour instead of three days.

The workflow is not "AI generates code and you ship it blind." It is closer to having a very fast junior developer who produces a solid first draft that a senior developer reviews, refines, and integrates. The AI handles the mechanical translation; the developer handles the judgment calls about responsive behavior, data binding, and edge cases.

Step-by-Step Walkthrough

Step 1: Share the Design and Specify the Stack

The more context the agent has about the tech stack, the better the output. Three things matter most:

  • Component library (shadcn/ui vs Radix vs Material UI) -- determines how primitives like accordions and dialogs are built
  • CSS approach (Tailwind vs CSS Modules vs styled-components) -- determines how design tokens map to code
  • Existing conventions -- if the codebase already has a Button or Card component, the agent should use it rather than generating a new one
Here's our new pricing page design: https://figma.com/file/abc123/Pricing-Page
We use React, TypeScript, Tailwind CSS, and shadcn/ui. Generate
production-ready components.

Step 2: Extract Design Structure and Tokens

The agent analyzes the Figma file frame by frame, mapping the component hierarchy and extracting everything a developer would normally spend an hour pulling from the inspector panel. The extraction is not just about colors and spacing — it captures the semantic structure: which elements are headings, which are interactive, and how components relate to each other.

Frame 1: Hero Section (1440x480)

  • Headline: Inter 48px/56px semibold, #0F172A
  • Subtext: Inter 18px/28px regular, #64748B
  • Background: linear-gradient(135deg, #EFF6FF, #F8FAFC)

Frame 2: Pricing Cards (1440x520)

  • 3-column grid, 24px gap
  • Card: 384px wide, 16px padding, rounded-xl, shadow-md
  • Highlighted card: ring-2 ring-blue-500, scale-105
  • CTA button: blue-600, rounded-lg, full-width

Frame 3: FAQ Accordion (1440x400)

  • Max-width 768px, centered
  • 8 items, border-b separator
  • Chevron rotation animation on expand: 0deg to 180deg, 200ms ease

Every value maps directly to Tailwind classes. No guessing, no eyeballing. The extraction also catches design inconsistencies early — if the designer used #64748B in the hero but #6B7280 in the footer for the same semantic role, the agent flags the discrepancy. Catching these mismatches before code is written saves a review cycle.

Design tokens are extracted and consolidated into a single file, mapping Figma values to Tailwind utilities. The hero's Inter 48px/56px semibold becomes text-5xl font-semibold leading-[56px], and that mapping is reusable across every component.

Step 3: Receive Production-Ready Components

The agent generates five files, each with clean TypeScript and Tailwind — no hardcoded colors or magic numbers:

components/PricingHero.tsx (32 lines) -- responsive headline scaling from text-3xl on mobile to text-5xl on desktop, gradient background using Tailwind arbitrary values. The subtext collapses to two lines on mobile with proper line clamping.

components/PricingCard.tsx (58 lines) -- the workhorse component. Props for name, price, period, features, highlighted, and onSelect. Includes a monthly/yearly toggle with animated price transition, a highlighted variant with ring and scale transform, and full keyboard accessibility on the CTA button.

typescript
// components/PricingCard.tsx
interface PricingCardProps {
  name: string;
  price: { monthly: number; yearly: number };
  features: string[];
  highlighted?: boolean;
  onSelect: (plan: string) => void;
}

export function PricingCard({ name, price, features, highlighted, onSelect }: PricingCardProps) {
  return (
    <div className={cn(
      "rounded-xl p-4 shadow-md",
      highlighted && "ring-2 ring-blue-500 scale-105"
    )}>
      {/* ... */}
    </div>
  );
}

components/PricingGrid.tsx (24 lines) -- 3-column layout on desktop, single column on mobile, highlighted card centered. Uses CSS Grid with auto-fit so it degrades gracefully if a fourth card is added later.

components/FaqAccordion.tsx (41 lines) -- built on the shadcn/ui Accordion primitive, accepts an array of { question, answer } items. Keyboard accessible out of the box (arrow keys navigate, Enter/Space toggle).

lib/pricing-tokens.ts (15 lines) -- exported design tokens for colors, spacing, and typography, all matching the Figma file exactly. These tokens become the source of truth — if the designer updates a color in Figma, changing it in one file updates every component.

All five files use the existing Tailwind config. No hardcoded colors, no magic pixel numbers, no !important overrides. The components slot into the existing codebase without any configuration changes.

This is where the approach differs from generic code generators: the output respects the project's existing conventions. If the codebase uses cn() from class-variance-authority for conditional classes, the generated code uses it too. If there is an existing Button component, the pricing card's CTA uses it rather than generating a new one.

Step 4: Refine Responsive Behavior

The first pass handles desktop and mobile breakpoints based on what is visible in the Figma frames. But designers often have opinions about tablet behavior that are not captured in static mockups — this is where the iterative refinement loop matters:

The cards should stack on mobile but I want a horizontal scroll on tablet
instead of stacking. Can you adjust?

The updated PricingGrid.tsx adds a third breakpoint:

  • Mobile (< 640px): single column stack
  • Tablet (640-1024px): horizontal scroll with CSS snap points — overflow-x-auto snap-x snap-mandatory, each card gets snap-center min-w-[320px]. Scroll padding ensures the first card is not flush against the edge.
  • Desktop (> 1024px): 3-column grid, unchanged

Touch-friendly scroll indicators show on tablet so users know the content is scrollable. The change takes minutes, not the hour it would take to implement from scratch.

This iterative refinement is where the workflow really pays off. Instead of explaining responsive behavior in a Figma comment and hoping the developer interprets it correctly, the designer (or developer) describes the behavior in plain text and gets working code back immediately. The feedback loop shrinks from days to minutes.

Real-World Example

Sana is a frontend developer at a 20-person SaaS startup. The design team just finished a dashboard redesign — 8 new screens, 23 unique components, new data visualization patterns, and a refreshed color palette. The PM wants it shipped in two weeks. Normally this would take a month of frontend work, plus another week of design review and pixel-pushing.

Sana shares the Figma file with the agent and specifies the stack: Next.js, TypeScript, Tailwind, and their custom component library built on Radix primitives. The agent processes all 8 screens, identifies 14 truly unique components (the other 9 are variants of existing ones), and extracts a consistent token set that maps cleanly to the existing Tailwind config.

Over two days, Sana reviews and integrates the generated components — tweaking responsive breakpoints, wiring up data fetching, and adjusting a few animations. The agent nails about 85% of the CSS and JSX on the first pass, which saves roughly 50 hours of manual translation work.

For the remaining 15%, Sana screenshots the discrepancies ("the card shadow is too heavy on this component," "the chart legend wraps wrong at 768px") and the agent adjusts the specific values. Each fix takes a few minutes instead of the usual back-and-forth where a designer files a Jira ticket, a developer picks it up two days later, and the cycle repeats.

The dashboard redesign ships in 9 days instead of the projected four weeks. The design team reviews and finds only 3 minor spacing adjustments needed — down from the usual 20+ rounds of pixel-pushing feedback.

The real win is not just speed — it is what Sana spent her time on. Instead of three weeks manually translating visual designs into CSS, she focused on the hard parts: data fetching, state management, real-time updates, and error states that the Figma file does not cover. The generated components handled the visual layer, and Sana handled the behavior layer. That division of labor is what makes the workflow sustainable, not just fast.

The design team now trusts that what they see in Figma will match what ships in production. That trust changes the entire dynamic — designers stop over-specifying (adding redlines to every element) because the code matches the design on the first pass. The feedback cycle that used to take a week now takes an afternoon.