Figma to Code
Overview
This skill converts Figma designs into production-ready frontend components. It extracts layout structure, spacing, typography, colors, and interactive states from designs and generates clean, responsive code using the team's existing tech stack and design system.
Instructions
Getting Design Information
There are three ways to receive design input:
Figma URL — Extract via Figma REST API:
curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
"https://api.figma.com/v1/files/<file_key>/nodes?ids=<node_id>"
Parse the JSON response for layout, styles, and component structure.
Screenshot/Image — Analyze the image visually to identify:
- Layout grid (columns, gutters, margins)
- Component hierarchy (cards, headers, lists, forms)
- Typography scale (headings, body, captions)
- Color palette and spacing patterns
Exported Design Tokens — Parse JSON/CSS design tokens directly.
Generating Components
Identify the component tree — Break the design into a hierarchy:
- Page → Sections → Components → Elements
- Map each to a React/Vue component or HTML section
Extract design tokens:
- Colors: Map to CSS custom properties or theme variables
- Typography: Font family, size, weight, line-height, letter-spacing
- Spacing: Padding, margin, gap values — normalize to a spacing scale (4px base)
- Border radius, shadows, opacity
Generate the code following these rules:
- Use semantic HTML (
<nav>, <main>, <article>, <section>)
- Use CSS Grid or Flexbox for layout — never absolute positioning for flow content
- Make it responsive: mobile-first, use
clamp() for fluid typography
- Use the team's existing component library if specified (e.g., Tailwind, shadcn/ui, MUI)
- Extract repeated patterns into reusable components
- Add proper ARIA attributes for accessibility
Handle responsive breakpoints:
- If the design shows multiple viewport sizes, implement all of them
- If only desktop is shown, create sensible mobile breakpoints:
- Stack horizontal layouts vertically below 768px
- Collapse navigation to a hamburger menu
- Adjust font sizes with
clamp()
Handle interactive states:
- Hover, focus, active, disabled states
- Loading skeletons where data is dynamic
- Empty states and error states if visible in the design
Output Structure
Deliver code as individual files:
components/
ComponentName/
ComponentName.tsx # Component code
ComponentName.module.css # Styles (or .tailwind if using Tailwind)
index.ts # Re-export
Examples
Example 1: Pricing Card from Figma Screenshot
User provides: Screenshot of a pricing card with three tiers
Agent output:
// components/PricingCard/PricingCard.tsx
interface PricingCardProps {
name: string;
price: number;
period: "monthly" | "yearly";
features: string[];
highlighted?: boolean;
onSelect: () => void;
}
export function PricingCard({ name, price, period, features, highlighted, onSelect }: PricingCardProps) {
return (
<article className={`${styles.card} ${highlighted ? styles.highlighted : ""}`}>
<h3 className={styles.planName}>{name}</h3>
<div className={styles.price}>
<span className={styles.currency}>$</span>
<span className={styles.amount}>{price}</span>
<span className={styles.period}>/{period === "monthly" ? "mo" : "yr"}</span>
</div>
<ul className={styles.features} role="list">
{features.map((feature) => (
<li key={feature} className={styles.feature}>
<CheckIcon aria-hidden="true" />
{feature}
</li>
))}
</ul>
<button className={styles.cta}
Get started
</button>
</article>
);
}
Example 2: Dashboard Layout from Figma URL
User provides: Figma URL to a dashboard with sidebar navigation, stats cards, and a data table
Agent extracts from API:
Layout: 240px fixed sidebar + fluid main content
Grid: Stats row (4 columns) + full-width table below
Colors: --bg-primary: #0F172A, --bg-surface: #1E293B, --accent: #3B82F6
Type scale: heading-lg: 24/32 Inter 600, body: 14/20 Inter 400
Agent generates: Sidebar component, StatsGrid component, DataTable component with responsive collapse behavior, and a shared theme file with extracted design tokens.
Guidelines
- Always ask which framework/library the team uses before generating code
- Prefer the team's existing design system tokens over hardcoded values
- Don't generate pixel values from designs without normalizing to a consistent scale
- Include alt text placeholders for images and meaningful ARIA labels
- Generate TypeScript interfaces for all component props
- If the design has inconsistent spacing, normalize it and flag the discrepancies
- Test responsive behavior — the design may only show one viewport size
- Never hardcode content strings — make them props or use i18n keys
1---2name: figma-to-code3description: Convert Figma designs into production-ready frontend code. Use when someone shares a Figma URL, design screenshot, or exported design tokens and needs React/Vue/HTML components, responsive layouts, or design system code. Trigger words: Figma, design to code, mockup, wireframe, UI implementation, pixel perfect, design handoff, component from design.4license: Apache-2.05---67# Figma to Code89## Overview1011This skill converts Figma designs into production-ready frontend components. It extracts layout structure, spacing, typography, colors, and interactive states from designs and generates clean, responsive code using the team's existing tech stack and design system.1213## Instructions1415### Getting Design Information1617There are three ways to receive design input:18191. **Figma URL** — Extract via Figma REST API:20 ```bash21 curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \22 "https://api.figma.com/v1/files/<file_key>/nodes?ids=<node_id>"23 ```24 Parse the JSON response for layout, styles, and component structure.25262. **Screenshot/Image** — Analyze the image visually to identify:27 - Layout grid (columns, gutters, margins)28 - Component hierarchy (cards, headers, lists, forms)29 - Typography scale (headings, body, captions)30 - Color palette and spacing patterns31323. **Exported Design Tokens** — Parse JSON/CSS design tokens directly.3334### Generating Components35361. **Identify the component tree** — Break the design into a hierarchy:37 - Page → Sections → Components → Elements38 - Map each to a React/Vue component or HTML section39402. **Extract design tokens:**41 - Colors: Map to CSS custom properties or theme variables42 - Typography: Font family, size, weight, line-height, letter-spacing43 - Spacing: Padding, margin, gap values — normalize to a spacing scale (4px base)44 - Border radius, shadows, opacity45463. **Generate the code following these rules:**47 - Use semantic HTML (`<nav>`, `<main>`, `<article>`, `<section>`)48 - Use CSS Grid or Flexbox for layout — never absolute positioning for flow content49 - Make it responsive: mobile-first, use `clamp()` for fluid typography50 - Use the team's existing component library if specified (e.g., Tailwind, shadcn/ui, MUI)51 - Extract repeated patterns into reusable components52 - Add proper ARIA attributes for accessibility53544. **Handle responsive breakpoints:**55 - If the design shows multiple viewport sizes, implement all of them56 - If only desktop is shown, create sensible mobile breakpoints:57 - Stack horizontal layouts vertically below 768px58 - Collapse navigation to a hamburger menu59 - Adjust font sizes with `clamp()`60615. **Handle interactive states:**62 - Hover, focus, active, disabled states63 - Loading skeletons where data is dynamic64 - Empty states and error states if visible in the design6566### Output Structure6768Deliver code as individual files:69```70components/71 ComponentName/72 ComponentName.tsx # Component code73 ComponentName.module.css # Styles (or .tailwind if using Tailwind)74 index.ts # Re-export75```7677## Examples7879### Example 1: Pricing Card from Figma Screenshot8081**User provides:** Screenshot of a pricing card with three tiers8283**Agent output:**84```tsx85// components/PricingCard/PricingCard.tsx86interface PricingCardProps {87 name: string;88 price: number;89 period: "monthly" | "yearly";90 features: string[];91 highlighted?: boolean;92 onSelect: () => void;93}9495export function PricingCard({ name, price, period, features, highlighted, onSelect }: PricingCardProps) {96 return (97 <article className={`${styles.card} ${highlighted ? styles.highlighted : ""}`}>98 <h3 className={styles.planName}>{name}</h3>99 <div className={styles.price}>100 <span className={styles.currency}>$</span>101 <span className={styles.amount}>{price}</span>102 <span className={styles.period}>/{period === "monthly" ? "mo" : "yr"}</span>103 </div>104 <ul className={styles.features} role="list">105 {features.map((feature) => (106 <li key={feature} className={styles.feature}>107 <CheckIcon aria-hidden="true" />108 {feature}109 </li>110 ))}111 </ul>112 <button className={styles.cta} onClick={onSelect}>113 Get started114 </button>115 </article>116 );117}118```119120### Example 2: Dashboard Layout from Figma URL121122**User provides:** Figma URL to a dashboard with sidebar navigation, stats cards, and a data table123124**Agent extracts from API:**125```126Layout: 240px fixed sidebar + fluid main content127Grid: Stats row (4 columns) + full-width table below128Colors: --bg-primary: #0F172A, --bg-surface: #1E293B, --accent: #3B82F6129Type scale: heading-lg: 24/32 Inter 600, body: 14/20 Inter 400130```131132**Agent generates:** Sidebar component, StatsGrid component, DataTable component with responsive collapse behavior, and a shared theme file with extracted design tokens.133134## Guidelines135136- Always ask which framework/library the team uses before generating code137- Prefer the team's existing design system tokens over hardcoded values138- Don't generate pixel values from designs without normalizing to a consistent scale139- Include alt text placeholders for images and meaningful ARIA labels140- Generate TypeScript interfaces for all component props141- If the design has inconsistent spacing, normalize it and flag the discrepancies142- Test responsive behavior — the design may only show one viewport size143- Never hardcode content strings — make them props or use i18n keys