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: >-4 Convert Figma designs into production-ready frontend code. Use when someone5 shares a Figma URL, design screenshot, or exported design tokens and needs6 React/Vue/HTML components, responsive layouts, or design system code. Trigger7 words: Figma, design to code, mockup, wireframe, UI implementation, pixel8 perfect, design handoff, component from design.9license: Apache-2.010compatibility: "Works with Figma URLs (requires Figma API token), screenshots, or exported design specs"11metadata:12 source: https://skillmd.com/skills/eliferjunior/figma-to-code13 author: terminal-skills14 version: "1.0.0"15 category: design16 tags: ["figma", "frontend", "design-to-code", "react", "css"]17---1819# Figma to Code2021## Overview2223This 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.2425## Instructions2627### Getting Design Information2829There are three ways to receive design input:30311. **Figma URL** — Extract via Figma REST API:32 ```bash33 curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \34 "https://api.figma.com/v1/files/<file_key>/nodes?ids=<node_id>"35 ```36 Parse the JSON response for layout, styles, and component structure.37382. **Screenshot/Image** — Analyze the image visually to identify:39 - Layout grid (columns, gutters, margins)40 - Component hierarchy (cards, headers, lists, forms)41 - Typography scale (headings, body, captions)42 - Color palette and spacing patterns43443. **Exported Design Tokens** — Parse JSON/CSS design tokens directly.4546### Generating Components47481. **Identify the component tree** — Break the design into a hierarchy:49 - Page → Sections → Components → Elements50 - Map each to a React/Vue component or HTML section51522. **Extract design tokens:**53 - Colors: Map to CSS custom properties or theme variables54 - Typography: Font family, size, weight, line-height, letter-spacing55 - Spacing: Padding, margin, gap values — normalize to a spacing scale (4px base)56 - Border radius, shadows, opacity57583. **Generate the code following these rules:**59 - Use semantic HTML (`<nav>`, `<main>`, `<article>`, `<section>`)60 - Use CSS Grid or Flexbox for layout — never absolute positioning for flow content61 - Make it responsive: mobile-first, use `clamp()` for fluid typography62 - Use the team's existing component library if specified (e.g., Tailwind, shadcn/ui, MUI)63 - Extract repeated patterns into reusable components64 - Add proper ARIA attributes for accessibility65664. **Handle responsive breakpoints:**67 - If the design shows multiple viewport sizes, implement all of them68 - If only desktop is shown, create sensible mobile breakpoints:69 - Stack horizontal layouts vertically below 768px70 - Collapse navigation to a hamburger menu71 - Adjust font sizes with `clamp()`72735. **Handle interactive states:**74 - Hover, focus, active, disabled states75 - Loading skeletons where data is dynamic76 - Empty states and error states if visible in the design7778### Output Structure7980Deliver code as individual files:81```82components/83 ComponentName/84 ComponentName.tsx # Component code85 ComponentName.module.css # Styles (or .tailwind if using Tailwind)86 index.ts # Re-export87```8889## Examples9091### Example 1: Pricing Card from Figma Screenshot9293**User provides:** Screenshot of a pricing card with three tiers9495**Agent output:**96```tsx97// components/PricingCard/PricingCard.tsx98interface PricingCardProps {99 name: string;100 price: number;101 period: "monthly" | "yearly";102 features: string[];103 highlighted?: boolean;104 onSelect: () => void;105}106107export function PricingCard({ name, price, period, features, highlighted, onSelect }: PricingCardProps) {108 return (109 <article className={`${styles.card} ${highlighted ? styles.highlighted : ""}`}>110 <h3 className={styles.planName}>{name}</h3>111 <div className={styles.price}>112 <span className={styles.currency}>$</span>113 <span className={styles.amount}>{price}</span>114 <span className={styles.period}>/{period === "monthly" ? "mo" : "yr"}</span>115 </div>116 <ul className={styles.features} role="list">117 {features.map((feature) => (118 <li key={feature} className={styles.feature}>119 <CheckIcon aria-hidden="true" />120 {feature}121 </li>122 ))}123 </ul>124 <button className={styles.cta} onClick={onSelect}>125 Get started126 </button>127 </article>128 );129}130```131132### Example 2: Dashboard Layout from Figma URL133134**User provides:** Figma URL to a dashboard with sidebar navigation, stats cards, and a data table135136**Agent extracts from API:**137```138Layout: 240px fixed sidebar + fluid main content139Grid: Stats row (4 columns) + full-width table below140Colors: --bg-primary: #0F172A, --bg-surface: #1E293B, --accent: #3B82F6141Type scale: heading-lg: 24/32 Inter 600, body: 14/20 Inter 400142```143144**Agent generates:** Sidebar component, StatsGrid component, DataTable component with responsive collapse behavior, and a shared theme file with extracted design tokens.145146## Guidelines147148- Always ask which framework/library the team uses before generating code149- Prefer the team's existing design system tokens over hardcoded values150- Don't generate pixel values from designs without normalizing to a consistent scale151- Include alt text placeholders for images and meaningful ARIA labels152- Generate TypeScript interfaces for all component props153- If the design has inconsistent spacing, normalize it and flag the discrepancies154- Test responsive behavior — the design may only show one viewport size155- Never hardcode content strings — make them props or use i18n keys