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: Figma to Code4---5# Figma to Code67## Overview89This 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.1011## Instructions1213### Getting Design Information1415There are three ways to receive design input:16171. **Figma URL** — Extract via Figma REST API:18 ```bash19 curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \20 "https://api.figma.com/v1/files/<file_key>/nodes?ids=<node_id>"21 ```22 Parse the JSON response for layout, styles, and component structure.23242. **Screenshot/Image** — Analyze the image visually to identify:25 - Layout grid (columns, gutters, margins)26 - Component hierarchy (cards, headers, lists, forms)27 - Typography scale (headings, body, captions)28 - Color palette and spacing patterns29303. **Exported Design Tokens** — Parse JSON/CSS design tokens directly.3132### Generating Components33341. **Identify the component tree** — Break the design into a hierarchy:35 - Page → Sections → Components → Elements36 - Map each to a React/Vue component or HTML section37382. **Extract design tokens:**39 - Colors: Map to CSS custom properties or theme variables40 - Typography: Font family, size, weight, line-height, letter-spacing41 - Spacing: Padding, margin, gap values — normalize to a spacing scale (4px base)42 - Border radius, shadows, opacity43443. **Generate the code following these rules:**45 - Use semantic HTML (`<nav>`, `<main>`, `<article>`, `<section>`)46 - Use CSS Grid or Flexbox for layout — never absolute positioning for flow content47 - Make it responsive: mobile-first, use `clamp()` for fluid typography48 - Use the team's existing component library if specified (e.g., Tailwind, shadcn/ui, MUI)49 - Extract repeated patterns into reusable components50 - Add proper ARIA attributes for accessibility51524. **Handle responsive breakpoints:**53 - If the design shows multiple viewport sizes, implement all of them54 - If only desktop is shown, create sensible mobile breakpoints:55 - Stack horizontal layouts vertically below 768px56 - Collapse navigation to a hamburger menu57 - Adjust font sizes with `clamp()`58595. **Handle interactive states:**60 - Hover, focus, active, disabled states61 - Loading skeletons where data is dynamic62 - Empty states and error states if visible in the design6364### Output Structure6566Deliver code as individual files:67```68components/69 ComponentName/70 ComponentName.tsx # Component code71 ComponentName.module.css # Styles (or .tailwind if using Tailwind)72 index.ts # Re-export73```7475## Examples7677### Example 1: Pricing Card from Figma Screenshot7879**User provides:** Screenshot of a pricing card with three tiers8081**Agent output:**82```tsx83// components/PricingCard/PricingCard.tsx84interface PricingCardProps {85 name: string;86 price: number;87 period: "monthly" | "yearly";88 features: string[];89 highlighted?: boolean;90 onSelect: () => void;91}9293export function PricingCard({ name, price, period, features, highlighted, onSelect }: PricingCardProps) {94 return (95 <article className={`${styles.card} ${highlighted ? styles.highlighted : ""}`}>96 <h3 className={styles.planName}>{name}</h3>97 <div className={styles.price}>98 <span className={styles.currency}>$</span>99 <span className={styles.amount}>{price}</span>100 <span className={styles.period}>/{period === "monthly" ? "mo" : "yr"}</span>101 </div>102 <ul className={styles.features} role="list">103 {features.map((feature) => (104 <li key={feature} className={styles.feature}>105 <CheckIcon aria-hidden="true" />106 {feature}107 </li>108 ))}109 </ul>110 <button className={styles.cta} onClick={onSelect}>111 Get started112 </button>113 </article>114 );115}116```117118### Example 2: Dashboard Layout from Figma URL119120**User provides:** Figma URL to a dashboard with sidebar navigation, stats cards, and a data table121122**Agent extracts from API:**123```124Layout: 240px fixed sidebar + fluid main content125Grid: Stats row (4 columns) + full-width table below126Colors: --bg-primary: #0F172A, --bg-surface: #1E293B, --accent: #3B82F6127Type scale: heading-lg: 24/32 Inter 600, body: 14/20 Inter 400128```129130**Agent generates:** Sidebar component, StatsGrid component, DataTable component with responsive collapse behavior, and a shared theme file with extracted design tokens.131132## Guidelines133134- Always ask which framework/library the team uses before generating code135- Prefer the team's existing design system tokens over hardcoded values136- Don't generate pixel values from designs without normalizing to a consistent scale137- Include alt text placeholders for images and meaningful ARIA labels138- Generate TypeScript interfaces for all component props139- If the design has inconsistent spacing, normalize it and flag the discrepancies140- Test responsive behavior — the design may only show one viewport size141- Never hardcode content strings — make them props or use i18n keys