Translate UI/UX designs into production-ready, accessible, responsive
frontend code. This skill turns an agent into a design-aware implementation
engine that extracts design tokens, maps component hierarchies, applies
accessibility standards, and produces framework-appropriate code — not just
a design export.
Accessible markup, ARIA, focus management, color contrast
🛠️ Implement
Generate framework-appropriate code
Component files, styles, tests
🧪 Verify
Visual regression testing and design QA
Test snapshots, diff reports, checklist
Quality Tiers:
💎 Production — Accessible, responsive, tested, framework-native, token-driven
🥈 MVP — Functional across breakpoints, basic accessibility, inline styles OK for speed
🥉 Prototype — Single viewport, minimal accessibility, rapid iteration
When to Use This Skill
Activate this skill when the user asks you to:
"Turn this Figma design into code" / "Convert this mockup to React/Vue/Svelte"
"Implement this design" / "Build this UI from this screenshot"
"Extract design tokens from this Figma file" / "Create a design system from these specs"
"Make this design responsive" / "Add responsive breakpoints to this layout"
"Make this component accessible" / "Ensure WCAG 2.1 AA compliance"
"Set up a component from this Sketch/XD design"
"Create a pixel-perfect implementation of this design"
"Integrate this design with our existing design system"
"Set up visual regression tests for these components"
Any request containing "design" + "code", "implement", "build", "convert", or "translate"
Additionally, activate proactively when a conversation includes a design
artifact (Figma link, screenshot, design spec) and the user's intent is
implementation.
Do NOT Activate For
The following inputs are near-miss negatives — they mention design or
code language but are not design-to-code tasks:
Pure code generation without a design: "Write a React form component" — no visual design input, so plain coding.
Design critique/review: "What do you think of this design?" — opinion, not implementation.
Pure accessibility audit without implementation: "Audit this page for accessibility" — audit, not design-to-code.
Design tool usage questions: "How do I create an auto-layout in Figma?" — tool instruction, not code generation.
Backend/styling-less code: "Build a REST API for user management" — no visual design involved.
Pure CSS framework questions: "What's better, Tailwind or CSS Modules?" — opinion, not implementation.
Animating existing components: "Add a fade-in animation to this button" — micro-interaction on existing code, not a full design translation.
Logo/brand asset generation: "Create an SVG logo based on this brief" — graphic design output, not frontend implementation.
Design token management without code: "Organize our design tokens in Figma" — design tool work, not code.
When in doubt, ask: "Do you have a design you want me to translate into
code, or are you asking me to work directly with code/design concepts?"
Common Pitfalls & Anti-Patterns
❌ Implementer Anti-Patterns
Skipping the design analysis phase — Jumping straight to code without
understanding the design's intent, hierarchy, and reusable patterns. Always
ingest and analyze before you code.
Hardcoding design values — Using raw pixel values (color: #3B82F6)
instead of design tokens (color: var(--color-primary-500)). Token-driven
code is maintainable; hardcoded values rot.
Accessibility as an afterthought — Adding ARIA at the end rather than
building accessible from the start. Retrofit accessibility is always
incomplete.
Responsive as a second pass — Implementing desktop-first then
"making it responsive" leads to fragile media-query spaghetti. Plan
breakpoints and layout strategy before writing a single rule.
Div-soup markup — Nesting <div> inside <div> rather than using
semantic HTML (<nav>, <main>, <section>, <article>, <aside>).
Semantic elements are free accessibility and SEO wins.
Over-engineering the component tree — Creating 12 components for a
simple card because "atomic design says so." Map hierarchy to what the
design actually calls for, not an ideology.
Copying Figma auto-layout directly — Figma's stacking model doesn't
always map 1:1 to CSS Flexbox/Grid. Translate the intent, not the
implementation.
Ignoring existing design system tokens — Using colors/spacing that
diverge from the project's token set. "Close enough" values accumulate
into an inconsistent codebase.
Testing only one viewport — Verifying at 1440px and calling it done.
Every breakpoint, every browser, every component state needs verification.
Skipping visual regression testing — Assuming your implementation
matches the design because it "looks right." Screenshot diffs catch
what the human eye misses.
✅ Implementation Quality Checklist
Before declaring a design-to-code task complete, verify:
All design sources were ingested and analyzed
Design tokens are extracted and referenced as CSS custom properties or token variables
Component hierarchy matches the design's visual hierarchy
All defined breakpoints have been implemented and tested
WCAG 2.1 AA compliance verified (contrast, focus, labels, semantics)
Framework conventions followed (component structure, styling approach)
No hardcoded design values — all through tokens
Visual regression baselines captured and tests pass
Component states accounted for (hover, focus, active, disabled, loading, empty, error)
Keyboard navigation works end-to-end
Screen reader announcement is meaningful
Dark mode / theme variants considered (if applicable)
Workflow
Phase 1: Ingest the Design Source
Identify the design source type:
Figma: Extract via Figma API, Figma plugin export, or screenshot +
manual annotation. For API access, use the Figma file key and node IDs.
Sketch: Parse .sketch files (they are ZIP archives with JSON inside).
Extract via unzip and read document.json + pages/.
Adobe XD: Export via XD plugin or Adobe's Design Automation API.
Screenshots / image files: Use image analysis (vision model) to
identify layout, colors, typography, spacing, and components. If a
screenshot is the only input, acknowledge the precision limitation.
Design specs / redlines: Parse spec documents for explicit
measurements, colors, and type scales.
Normalize the design data. Regardless of source, produce:
Color palette — all named colors with hex/RGB/HSL values
Typography scale — font families, sizes, weights, line heights,
letter spacing per text style
Spacing scale — consistent spacing units (4px/8px base recommended)
Shadow definitions — box-shadow values per elevation level
Border radii — consistent corner radius tokens
Component inventory — every distinct UI element, its states, and
how it repeats
If the design source is incomplete (screenshot, rough mockup), ask the
user for clarification on:
Exact color values (approximated from a screenshot may be off)
Font family names (not guessable from a screenshot)
Interactive states not visible in a static image
Responsive behaviour at different breakpoints
Phase 2: Extract and Define Design Tokens
Extract a structured token system. Use CSS custom properties as the canonical
format and derive framework-specific versions.
States — default, hover, focus, active, disabled, loading, empty,
error (list all that apply)
Variants — primary/secondary for buttons, compact/default/expanded
for cards, etc.
Slots/children — where does content get injected
Responsive behaviour — how does it change at each breakpoint
Identify shared/reusable patterns:
Buttons, inputs, cards, avatars — extract as base components
Layout primitives — Container, Grid, Stack, Flex
Typography components — Heading, Text, Caption
For each reusable component, check if an equivalent exists in the
project's design system. If yes, extend it rather than creating a new one.
Phase 4: Define Responsive Breakpoint Strategy
Choose a breakpoint system:
Mobile-first (recommended): Start at the smallest viewport and add
complexity as screen size increases. Use min-width media queries.
Desktop-first: Start at the largest viewport and simplify for
smaller screens. Use max-width media queries. Less common but valid
for desktop-heavy applications.
Define breakpoint values. Common breakpoints:
Name
Width
Typical Device
xs
0px+
All phones
sm
640px+
Large phones, small tablets
md
768px+
Tablets
lg
1024px+
Small laptops, large tablets landscape
xl
1280px+
Desktops
2xl
1536px+
Large desktops
For each breakpoint, document layout changes:
Component
< 640px
640–1024px
> 1024px
Navigation
Hamburger menu
Hamburger menu
Horizontal nav
FeatureGrid
1 column
2 columns
3 columns
HeroBanner
Stacked (image below text)
Stacked
Side-by-side
Sidebar
Hidden, toggle overlay
Collapsible
Persistent
Implement responsive utilities. Create CSS custom properties or
utility classes for media queries. For Tailwind, use the built-in
breakpoint prefixes (sm:, md:, lg:, xl:).
Test at every breakpoint. Do not trust that a component will work at
intermediate sizes. 720px can expose layout bugs that 640px and 768px
hide.
Phase 5: Accessibility-First Implementation
Minimum standard: WCAG 2.1 Level AA. If the user's project requires AAA,
escalate accordingly.
5.1 Semantic HTML
Use the correct HTML element for every piece of content. This is the
single highest-impact accessibility decision.
Content
Correct Element
Avoid
Page header
<header>
<div class="header">
Primary navigation
<nav aria-label="Main">
<div class="nav">
Main content
<main>
<div class="content">
Standalone sections
<section> (with heading)
<div>
Articles / blog posts
<article>
<div>
Sidebar / complementary
<aside>
<div>
Page footer
<footer>
<div class="footer">
Data tables
<table>, <thead>, <tbody>, <th scope="">
<div> grid
Lists of items
<ul>, <ol>, <li>
<div> repeated
Buttons that perform actions
<button>
<div>
Links that navigate
<a href="">
<button>
Images with meaning
<img alt="description">
<img> (missing alt)
Decorative images
<img alt="">
<img alt="icon">
Form inputs
<label> + <input> paired with for/id
Placeholder-only inputs
Headings
<h1>–<h6> in logical order (no skips)
<div class="heading">
Figures with captions
<figure> + <figcaption>
<div> + <p>
5.2 ARIA — Use Only When HTML Isn't Enough
First rule of ARIA: don't use ARIA if native HTML can do it. ARIA adds
complexity and is easy to get wrong.
Text contrast ratio: 4.5:1 minimum for normal text, 3:1 for large text
(18px+ bold or 24px+ regular). WCAG AA requirement.
Non-text contrast: 3:1 minimum for UI components and graphical objects
(button borders, input borders, icons).
Never use color alone to convey information. Error states need both
red color AND an icon/text indicator. Links need underlines (not just
color change).
Focus indicators: Every interactive element must have a visible focus
style. Default outline is fine; custom focus rings must have 3:1
contrast against adjacent colors. :focus-visible is preferred over
:focus for mouse users.
Tab order must follow visual order. Avoid positive tabindex values;
use tabindex="0" to add to the natural order or tabindex="-1" for
programmatic focus only.
Interactive elements must be reachable and operable via keyboard:
buttons, links, form controls, custom widgets.
Skip links: Provide a "Skip to main content" link as the first
focusable element.
Modals: Trap focus inside the modal while open. Restore focus to the
trigger element on close.
When the project has an existing design system, integrate without disruption.
Audit the existing system — what tokens, components, and patterns
already exist?
Map new design elements to existing tokens:
If the design uses a color that matches --color-primary-500, use it.
If the design introduces a new color not in the system, flag it:
"This design specifies #7C3AED which is not in our design system.
The closest existing token is --color-secondary-600 (#7C3AED is
an exact match to our secondary-600 — recommend using it)."
Extend components rather than creating duplicates. If a Card
component exists but the design needs a slightly different variant,
add a prop rather than creating SpecialCard.
If the design contradicts the design system, flag the discrepancy
and ask whether the design should change or the design system should
be updated.
Token synchronization — If the project has a token pipeline (e.g.,
Style Dictionary → CSS + JS + Tailwind config), update the source of
truth, not the generated files.
Safety Rules
ABSOLUTE RULES — never violate these:
Respect intellectual property. Never reproduce copyrighted designs,
illustrations, logos, or brand assets without explicit permission or
license. If a user provides a design from Dribbble, Behance, or a
competitor's website and asks you to clone it, refuse: "I cannot
reproduce this design because it appears to be copyrighted/owned by
[entity]. I can help you create an original design inspired by UI
patterns but not a direct copy."
Never ship hardcoded secrets. If a design includes API keys,
tokens, or credentials in code examples, flag them and strip them.
Use environment variables.
Always use HTTPS for external assets (fonts, images, CDN resources).
Mixed content is a security risk.
Respect user privacy. Don't add third-party trackers, analytics,
or telemetry to generated code without the user's explicit request.
Screen readers and accessibility tools must not be blocked.
Be honest about fidelity. When working from a screenshot (not a
design file), preface output with: "I'm working from a screenshot,
so colors and exact measurements are approximate. Please verify
the following values against your design spec."
Don't silently replace the design intent. If the design has a
complex interaction that would be expensive to implement, don't
simplify it without asking. Say: "This carousel pattern would take
~4 hours to implement with full accessibility. A simpler tabbed
layout would take ~1 hour. Which do you prefer?"
Accessibility is non-negotiable. Every implementation must meet
WCAG 2.1 AA at minimum. If the user explicitly asks to skip
accessibility, warn them but comply with the caveat noted.
Don't generate inaccessibly. Never produce code with outline: none
without a replacement focus indicator. Never use tabindex values
greater than 0. Never skip heading levels or use non-semantic markup
where semantic elements exist.
Platform Compatibility Notes
This skill is designed to work across AI coding platforms with minor
adaptations:
Platform
Notes
Claude Code
Figma API integration works well. Can parse design JSON. Good for token extraction pipelines.
Codex (OpenAI)
Strong at component generation. Paste design specs or describe the design verbally. Screenshot analysis works well.
Cursor
Can read existing codebase for design system context. File system access helps with token integration.
Gemini CLI
Large context window useful for ingesting full design specs. Use web_fetch for Figma API.
OpenClaw
Exec for Figma CLI/API calls. GitHub skill for PR-based design review. Image analysis for screenshots.
GitHub Copilot
Works within IDE context. Best for incremental component implementation with existing design system access.
Windsurf
Can access workspace files and design assets. Execute design-to-code in context of existing project.
OpenCode
Terminal-based. Best with explicit design specs pasted or described textually. Can run token extraction scripts.
Platform-Specific Adjustments
If Figma API token is unavailable: ask the user to export the design as
SVG/PNG or paste a design spec document. Screenshot analysis is the fallback.
If image/vision analysis is not available: ask the user to describe the
design in text (layout, colors, typography, spacing). Work from description.
If a specific framework is not specified: default to the framework the
project already uses. If no project exists, ask the user.
For Discord/Slack delivery: use bullet lists, not markdown tables. Split
large code blocks across multiple messages. Wrap links in <>.
For platforms without file system access: inline tokens and styles
directly in generated output rather than referencing external files.
References
references/design-tokens-guide.md — W3C Design Tokens Community Group
specification and implementation guide
Chromatic — Visual regression testing for
Storybook
1---2name: design-to-code3description: Use this skill when translating UI/UX designs into production-ready frontend code. Handles design source ingestion (Figma, Sketch, Adobe XD, screenshots, design specs), design token extraction, component hierarchy mapping, responsive breakpoint strategy, accessibility-first implementation (WCAG 2.1 AA minimum), framework-agnostic patterns (React, Vue, Svelte, plain HTML/CSS), design system integration, visual regression testing, and CSS architecture selection (CSS Modules, Tailwind, styled-components). Primary keyword clusters: design to code conversion, figma to react, design token extraction, UI component architecture, accessibility implementation WCAG, responsive design breakpoints, pixel perfect implementation, design system integration, CSS architecture patterns, visual regression testing strategy. Designed for agentic platforms — Claude Code, Codex, Cursor, Gemini CLI, OpenClaw, GitHub Copilot, Windsurf, and OpenCode.4---56# Design-to-Code Agent Skill78Translate UI/UX designs into production-ready, accessible, responsive9frontend code. This skill turns an agent into a design-aware implementation10engine that extracts design tokens, maps component hierarchies, applies11accessibility standards, and produces framework-appropriate code — not just12a design export.1314---1516## Quick Reference1718| Phase | What to Do | Key Deliverables |19|---|---|---|20| 🎨 Ingest | Load design source (Figma, Sketch, screenshot, spec) | Normalized design data, color palette, type scale |21| 🗂️ Extract Tokens | Pull colors, typography, spacing, shadows, radii | Design token JSON/CSS custom properties |22| 🧩 Map Components | Identify component tree, states, variants | Component hierarchy diagram, prop interfaces |23| 📐 Plan Responsive | Define breakpoints and layout behaviour | Breakpoint table, layout strategy per component |24| ♿ Accessibility | Audit and implement WCAG 2.1 AA | Accessible markup, ARIA, focus management, color contrast |25| 🛠️ Implement | Generate framework-appropriate code | Component files, styles, tests |26| 🧪 Verify | Visual regression testing and design QA | Test snapshots, diff reports, checklist |2728**Quality Tiers:**29- 💎 **Production** — Accessible, responsive, tested, framework-native, token-driven30- 🥈 **MVP** — Functional across breakpoints, basic accessibility, inline styles OK for speed31- 🥉 **Prototype** — Single viewport, minimal accessibility, rapid iteration3233---3435## When to Use This Skill3637Activate this skill when the user asks you to:3839- "Turn this Figma design into code" / "Convert this mockup to React/Vue/Svelte"40- "Implement this design" / "Build this UI from this screenshot"41- "Extract design tokens from this Figma file" / "Create a design system from these specs"42- "Make this design responsive" / "Add responsive breakpoints to this layout"43- "Make this component accessible" / "Ensure WCAG 2.1 AA compliance"44- "Set up a component from this Sketch/XD design"45- "Create a pixel-perfect implementation of this design"46- "Integrate this design with our existing design system"47- "Set up visual regression tests for these components"48- Any request containing "design" + "code", "implement", "build", "convert", or "translate"4950Additionally, activate proactively when a conversation includes a design51artifact (Figma link, screenshot, design spec) and the user's intent is52implementation.5354### Do NOT Activate For5556The following inputs are **near-miss negatives** — they mention design or57code language but are not design-to-code tasks:5859- **Pure code generation without a design**: "Write a React form component" — no visual design input, so plain coding.60- **Design critique/review**: "What do you think of this design?" — opinion, not implementation.61- **Pure accessibility audit without implementation**: "Audit this page for accessibility" — audit, not design-to-code.62- **Design tool usage questions**: "How do I create an auto-layout in Figma?" — tool instruction, not code generation.63- **Backend/styling-less code**: "Build a REST API for user management" — no visual design involved.64- **Pure CSS framework questions**: "What's better, Tailwind or CSS Modules?" — opinion, not implementation.65- **Animating existing components**: "Add a fade-in animation to this button" — micro-interaction on existing code, not a full design translation.66- **Logo/brand asset generation**: "Create an SVG logo based on this brief" — graphic design output, not frontend implementation.67- **Design token management without code**: "Organize our design tokens in Figma" — design tool work, not code.6869When in doubt, ask: "Do you have a design you want me to translate into70code, or are you asking me to work directly with code/design concepts?"7172---7374## Common Pitfalls & Anti-Patterns7576### ❌ Implementer Anti-Patterns77781. **Skipping the design analysis phase** — Jumping straight to code without79 understanding the design's intent, hierarchy, and reusable patterns. Always80 ingest and analyze before you code.81822. **Hardcoding design values** — Using raw pixel values (`color: #3B82F6`)83 instead of design tokens (`color: var(--color-primary-500)`). Token-driven84 code is maintainable; hardcoded values rot.85863. **Accessibility as an afterthought** — Adding ARIA at the end rather than87 building accessible from the start. Retrofit accessibility is always88 incomplete.89904. **Responsive as a second pass** — Implementing desktop-first then91 "making it responsive" leads to fragile media-query spaghetti. Plan92 breakpoints and layout strategy before writing a single rule.93945. **Div-soup markup** — Nesting `<div>` inside `<div>` rather than using95 semantic HTML (`<nav>`, `<main>`, `<section>`, `<article>`, `<aside>`).96 Semantic elements are free accessibility and SEO wins.97986. **Over-engineering the component tree** — Creating 12 components for a99 simple card because "atomic design says so." Map hierarchy to what the100 design actually calls for, not an ideology.1011027. **Copying Figma auto-layout directly** — Figma's stacking model doesn't103 always map 1:1 to CSS Flexbox/Grid. Translate the intent, not the104 implementation.1051068. **Ignoring existing design system tokens** — Using colors/spacing that107 diverge from the project's token set. "Close enough" values accumulate108 into an inconsistent codebase.1091109. **Testing only one viewport** — Verifying at 1440px and calling it done.111 Every breakpoint, every browser, every component state needs verification.11211310. **Skipping visual regression testing** — Assuming your implementation114 matches the design because it "looks right." Screenshot diffs catch115 what the human eye misses.116117### ✅ Implementation Quality Checklist118119Before declaring a design-to-code task complete, verify:120121- [ ] All design sources were ingested and analyzed122- [ ] Design tokens are extracted and referenced as CSS custom properties or token variables123- [ ] Component hierarchy matches the design's visual hierarchy124- [ ] All defined breakpoints have been implemented and tested125- [ ] WCAG 2.1 AA compliance verified (contrast, focus, labels, semantics)126- [ ] Framework conventions followed (component structure, styling approach)127- [ ] No hardcoded design values — all through tokens128- [ ] Visual regression baselines captured and tests pass129- [ ] Component states accounted for (hover, focus, active, disabled, loading, empty, error)130- [ ] Keyboard navigation works end-to-end131- [ ] Screen reader announcement is meaningful132- [ ] Dark mode / theme variants considered (if applicable)133134---135136## Workflow137138### Phase 1: Ingest the Design Source1391401. **Identify the design source type:**141 - **Figma**: Extract via Figma API, Figma plugin export, or screenshot +142 manual annotation. For API access, use the Figma file key and node IDs.143 ```bash144 # Extract Figma file as JSON145 curl -H "X-Figma-Token: $FIGMA_TOKEN" \146 "https://api.figma.com/v1/files/FILE_KEY"147 ```148 - **Sketch**: Parse `.sketch` files (they are ZIP archives with JSON inside).149 Extract via `unzip` and read `document.json` + `pages/`.150 - **Adobe XD**: Export via XD plugin or Adobe's Design Automation API.151 - **Screenshots / image files**: Use image analysis (vision model) to152 identify layout, colors, typography, spacing, and components. If a153 screenshot is the only input, acknowledge the precision limitation.154 - **Design specs / redlines**: Parse spec documents for explicit155 measurements, colors, and type scales.1561572. **Normalize the design data.** Regardless of source, produce:158 - **Color palette** — all named colors with hex/RGB/HSL values159 - **Typography scale** — font families, sizes, weights, line heights,160 letter spacing per text style161 - **Spacing scale** — consistent spacing units (4px/8px base recommended)162 - **Shadow definitions** — box-shadow values per elevation level163 - **Border radii** — consistent corner radius tokens164 - **Component inventory** — every distinct UI element, its states, and165 how it repeats1661673. **If the design source is incomplete** (screenshot, rough mockup), ask the168 user for clarification on:169 - Exact color values (approximated from a screenshot may be off)170 - Font family names (not guessable from a screenshot)171 - Interactive states not visible in a static image172 - Responsive behaviour at different breakpoints173174### Phase 2: Extract and Define Design Tokens175176Extract a structured token system. Use CSS custom properties as the canonical177format and derive framework-specific versions.178179```css180:root {181 /* Colors — Primary */182 --color-primary-50: #eff6ff;183 --color-primary-100: #dbeafe;184 --color-primary-200: #bfdbfe;185 --color-primary-300: #93c5fd;186 --color-primary-400: #60a5fa;187 --color-primary-500: #3b82f6;188 --color-primary-600: #2563eb;189 --color-primary-700: #1d4ed8;190 --color-primary-800: #1e40af;191 --color-primary-900: #1e3a8a;192193 /* Colors — Neutral */194 --color-neutral-50: #fafafa;195 --color-neutral-100: #f5f5f5;196 /* ...through 900 */197198 /* Typography */199 --font-family-sans: 'Inter', system-ui, -apple-system, sans-serif;200 --font-family-mono: 'JetBrains Mono', 'Fira Code', monospace;201202 --font-size-xs: 0.75rem; /* 12px */203 --font-size-sm: 0.875rem; /* 14px */204 --font-size-base: 1rem; /* 16px */205 --font-size-lg: 1.125rem; /* 18px */206 --font-size-xl: 1.25rem; /* 20px */207 --font-size-2xl: 1.5rem; /* 24px */208 --font-size-3xl: 1.875rem; /* 30px */209 --font-size-4xl: 2.25rem; /* 36px */210211 --font-weight-normal: 400;212 --font-weight-medium: 500;213 --font-weight-semibold: 600;214 --font-weight-bold: 700;215216 --line-height-tight: 1.25;217 --line-height-normal: 1.5;218 --line-height-relaxed: 1.75;219220 /* Spacing — 4px base scale */221 --space-1: 0.25rem; /* 4px */222 --space-2: 0.5rem; /* 8px */223 --space-3: 0.75rem; /* 12px */224 --space-4: 1rem; /* 16px */225 --space-5: 1.25rem; /* 20px */226 --space-6: 1.5rem; /* 24px */227 --space-8: 2rem; /* 32px */228 --space-10: 2.5rem; /* 40px */229 --space-12: 3rem; /* 48px */230 --space-16: 4rem; /* 64px */231 --space-20: 5rem; /* 80px */232233 /* Shadows */234 --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);235 --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);236 --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);237 --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);238239 /* Border Radius */240 --radius-sm: 0.125rem; /* 2px */241 --radius-md: 0.375rem; /* 6px */242 --radius-lg: 0.5rem; /* 8px */243 --radius-xl: 0.75rem; /* 12px */244 --radius-2xl: 1rem; /* 16px */245 --radius-full: 9999px;246}247```248249**Token naming conventions:**250- Use the [W3C Design Tokens Community Group format](https://tr.designtokens.org/)251 where possible: `color.primary.500`, `spacing.md`, `typography.heading.lg`.252- In CSS custom properties, use kebab-case dot-separated or dash-separated:253 `--color-primary-500` or `--typography-heading-lg`.254- For framework-specific code (Tailwind config, Theme UI, styled-system),255 derive the token structure from the CSS custom properties.256257**Token validation checklist:**258- [ ] All colors have a 50–900 scale (or a documented reason not to)259- [ ] Font sizes use relative units (`rem`) for accessibility260- [ ] Spacing uses a consistent base unit (4px or 8px)261- [ ] No raw values in component code — only token references262- [ ] Dark mode tokens defined if the design supports it263264See `references/design-tokens-guide.md` for the full W3C DTCG token265specification and advanced patterns.266267### Phase 3: Map the Component Hierarchy2682691. **Identify the top-level layout structure:**270 - Header, main content area, sidebar, footer271 - Page-level grid or layout container2722732. **Decompose into component tree:**274 ```275 Page276 ├── Header277 │ ├── Logo278 │ ├── Navigation279 │ │ └── NavItem (repeating)280 │ └── UserMenu281 │ ├── Avatar282 │ └── Dropdown283 ├── MainContent284 │ ├── HeroBanner285 │ │ ├── Heading286 │ │ ├── Subheading287 │ │ └── CTAButton288 │ ├── FeatureGrid289 │ │ └── FeatureCard (repeating)290 │ │ ├── Icon291 │ │ ├── Title292 │ │ └── Description293 │ └── TestimonialCarousel294 │ └── TestimonialCard (repeating)295 └── Footer296 ├── FooterLinks297 └── SocialIcons298 ```2993003. **For each component, define:**301 - **Props/interface** — what data flows in302 - **States** — default, hover, focus, active, disabled, loading, empty,303 error (list all that apply)304 - **Variants** — primary/secondary for buttons, compact/default/expanded305 for cards, etc.306 - **Slots/children** — where does content get injected307 - **Responsive behaviour** — how does it change at each breakpoint3083094. **Identify shared/reusable patterns:**310 - Buttons, inputs, cards, avatars — extract as base components311 - Layout primitives — Container, Grid, Stack, Flex312 - Typography components — Heading, Text, Caption3133145. **For each reusable component, check if an equivalent exists** in the315 project's design system. If yes, extend it rather than creating a new one.316317### Phase 4: Define Responsive Breakpoint Strategy3183191. **Choose a breakpoint system:**320 - **Mobile-first** (recommended): Start at the smallest viewport and add321 complexity as screen size increases. Use `min-width` media queries.322 - **Desktop-first**: Start at the largest viewport and simplify for323 smaller screens. Use `max-width` media queries. Less common but valid324 for desktop-heavy applications.3253262. **Define breakpoint values.** Common breakpoints:327 | Name | Width | Typical Device |328 |------|-------|----------------|329 | `xs` | 0px+ | All phones |330 | `sm` | 640px+ | Large phones, small tablets |331 | `md` | 768px+ | Tablets |332 | `lg` | 1024px+ | Small laptops, large tablets landscape |333 | `xl` | 1280px+ | Desktops |334 | `2xl` | 1536px+ | Large desktops |3353363. **For each breakpoint, document layout changes:**337 | Component | < 640px | 640–1024px | > 1024px |338 |-----------|---------|------------|----------|339 | Navigation | Hamburger menu | Hamburger menu | Horizontal nav |340 | FeatureGrid | 1 column | 2 columns | 3 columns |341 | HeroBanner | Stacked (image below text) | Stacked | Side-by-side |342 | Sidebar | Hidden, toggle overlay | Collapsible | Persistent |3433444. **Implement responsive utilities.** Create CSS custom properties or345 utility classes for media queries. For Tailwind, use the built-in346 breakpoint prefixes (`sm:`, `md:`, `lg:`, `xl:`).3473485. **Test at every breakpoint.** Do not trust that a component will work at349 intermediate sizes. 720px can expose layout bugs that 640px and 768px350 hide.351352### Phase 5: Accessibility-First Implementation353354**Minimum standard: WCAG 2.1 Level AA.** If the user's project requires AAA,355escalate accordingly.356357#### 5.1 Semantic HTML358359Use the correct HTML element for every piece of content. This is the360single highest-impact accessibility decision.361362| Content | Correct Element | Avoid |363|---------|----------------|-------|364| Page header | `<header>` | `<div class="header">` |365| Primary navigation | `<nav aria-label="Main">` | `<div class="nav">` |366| Main content | `<main>` | `<div class="content">` |367| Standalone sections | `<section>` (with heading) | `<div>` |368| Articles / blog posts | `<article>` | `<div>` |369| Sidebar / complementary | `<aside>` | `<div>` |370| Page footer | `<footer>` | `<div class="footer">` |371| Data tables | `<table>`, `<thead>`, `<tbody>`, `<th scope="">` | `<div>` grid |372| Lists of items | `<ul>`, `<ol>`, `<li>` | `<div>` repeated |373| Buttons that perform actions | `<button>` | `<div onclick="">` |374| Links that navigate | `<a href="">` | `<button onclick="navigate()">` |375| Images with meaning | `<img alt="description">` | `<img>` (missing alt) |376| Decorative images | `<img alt="">` | `<img alt="icon">` |377| Form inputs | `<label>` + `<input>` paired with `for`/`id` | Placeholder-only inputs |378| Headings | `<h1>`–`<h6>` in logical order (no skips) | `<div class="heading">` |379| Figures with captions | `<figure>` + `<figcaption>` | `<div>` + `<p>` |380381#### 5.2 ARIA — Use Only When HTML Isn't Enough382383**First rule of ARIA: don't use ARIA if native HTML can do it.** ARIA adds384complexity and is easy to get wrong.385386When ARIA is necessary:387388| Pattern | ARIA Usage |389|---------|-----------|390| Tabs | `role="tablist"`, `role="tab"`, `role="tabpanel"`, `aria-selected`, `aria-controls` |391| Modal dialogs | `role="dialog"`, `aria-modal="true"`, `aria-labelledby`, focus trap |392| Accordions | `aria-expanded` on trigger, `aria-controls` linking to panel |393| Live regions | `aria-live="polite"` for dynamic content updates |394| Custom dropdowns | `role="listbox"`, `role="option"`, `aria-activedescendant` |395| Alerts/toasts | `role="alert"` or `aria-live="assertive"` |396| Progress bars | `role="progressbar"`, `aria-valuenow`, `aria-valuemin`, `aria-valuemax` |397| Disclosure widgets | `aria-expanded`, `aria-controls` |398399#### 5.3 Color and Contrast400401- **Text contrast ratio**: 4.5:1 minimum for normal text, 3:1 for large text402 (18px+ bold or 24px+ regular). WCAG AA requirement.403- **Non-text contrast**: 3:1 minimum for UI components and graphical objects404 (button borders, input borders, icons).405- **Never use color alone** to convey information. Error states need both406 red color AND an icon/text indicator. Links need underlines (not just407 color change).408- **Focus indicators**: Every interactive element must have a visible focus409 style. Default `outline` is fine; custom focus rings must have 3:1410 contrast against adjacent colors. `:focus-visible` is preferred over411 `:focus` for mouse users.412413```css414/* Good focus indicator */415:focus-visible {416 outline: 3px solid var(--color-primary-500);417 outline-offset: 2px;418}419420/* Avoid — removes focus entirely */421*:focus { outline: none; }422```423424#### 5.4 Keyboard Navigation425426- **Tab order** must follow visual order. Avoid positive `tabindex` values;427 use `tabindex="0"` to add to the natural order or `tabindex="-1"` for428 programmatic focus only.429- **Interactive elements** must be reachable and operable via keyboard:430 buttons, links, form controls, custom widgets.431- **Skip links**: Provide a "Skip to main content" link as the first432 focusable element.433- **Modals**: Trap focus inside the modal while open. Restore focus to the434 trigger element on close.435- **Dropdown/Menus**: Arrow keys navigate items. Escape closes. Enter/Space436 selects.437438#### 5.5 Screen Reader Considerations439440- **Descriptive link text**: "Learn more about pricing" not "Click here".441- **Image alt text**: Describe what the image communicates, not what it is.442 "Golden retriever fetching a ball in a park" not "Photo of dog".443- **Form labels**: Every input must have an associated `<label>`. Use444 `aria-label` or `aria-labelledby` only when a visible label is not445 possible.446- **Dynamic content**: Use `aria-live` regions for content that updates447 without page reload (search results, chat messages, notifications).448- **Heading hierarchy**: One `<h1>` per page. Headings should form a logical449 outline without skipping levels (no `<h1>` to `<h3>` without `<h2>`).450451#### 5.6 Accessibility Audit Checklist452453Before shipping, verify:454- [ ] Page has a unique, descriptive `<title>`455- [ ] `<html>` has a `lang` attribute456- [ ] All images have appropriate `alt` text457- [ ] Color contrast meets WCAG AA minimums (use a checker tool)458- [ ] Focus order is logical and visible459- [ ] Skip link is present and functional460- [ ] Forms have associated labels and error messages461- [ ] Page is navigable by keyboard alone (try tabbing through)462- [ ] ARIA roles, states, and properties are valid (use axe DevTools or463 Lighthouse)464- [ ] Dynamic content updates are announced to screen readers465466### Phase 6: Framework-Agnostic Implementation Patterns467468Produce code appropriate to the project's framework. This skill does not469favor one framework — adapt to what the project uses.470471#### 6.1 React (with TypeScript)472473```tsx474// Button component — React + CSS Modules475import styles from './Button.module.css';476import { type ComponentPropsWithoutRef, forwardRef } from 'react';477478type ButtonVariant = 'primary' | 'secondary' | 'ghost';479type ButtonSize = 'sm' | 'md' | 'lg';480481interface ButtonProps extends ComponentPropsWithoutRef<'button'> {482 variant?: ButtonVariant;483 size?: ButtonSize;484 isLoading?: boolean;485}486487export const Button = forwardRef<HTMLButtonElement, ButtonProps>(488 ({ variant = 'primary', size = 'md', isLoading, children, disabled, className, ...props }, ref) => {489 const classes = [490 styles.button,491 styles[variant],492 styles[size],493 isLoading && styles.loading,494 className,495 ].filter(Boolean).join(' ');496497 return (498 <button499 ref={ref}500 className={classes}501 disabled={disabled || isLoading}502 aria-busy={isLoading}503 {...props}504 >505 {isLoading ? <Spinner size={size} /> : children}506 </button>507 );508 }509);510511Button.displayName = 'Button';512```513514#### 6.2 Vue 3 (Composition API)515516```vue517<script setup lang="ts">518import { computed } from 'vue';519520type ButtonVariant = 'primary' | 'secondary' | 'ghost';521type ButtonSize = 'sm' | 'md' | 'lg';522523const props = withDefaults(defineProps<{524 variant?: ButtonVariant;525 size?: ButtonSize;526 loading?: boolean;527 disabled?: boolean;528}>(), {529 variant: 'primary',530 size: 'md',531 loading: false,532 disabled: false,533});534535const classes = computed(() => [536 `btn btn--${props.variant}`,537 `btn--${props.size}`,538 { 'btn--loading': props.loading },539]);540</script>541542<template>543 <button544 :class="classes"545 :disabled="disabled || loading"546 :aria-busy="loading"547 >548 <Spinner v-if="loading" :size="size" />549 <slot v-else />550 </button>551</template>552```553554#### 6.3 Svelte555556```svelte557<script lang="ts">558 export let variant: 'primary' | 'secondary' | 'ghost' = 'primary';559 export let size: 'sm' | 'md' | 'lg' = 'md';560 export let loading = false;561 export let disabled = false;562</script>563564<button565 class="btn btn--{variant} btn--{size}"566 class:btn--loading={loading}567 {disabled}568 aria-busy={loading}569 on:click570 {...$$restProps}571>572 {#if loading}573 <Spinner {size} />574 {:else}575 <slot />576 {/if}577</button>578```579580#### 6.4 Plain HTML/CSS (Web Components)581582```html583<!-- Usage -->584<ds-button variant="primary" size="md">Click me</ds-button>585586<script>587class DsButton extends HTMLElement {588 static observedAttributes = ['variant', 'size', 'loading', 'disabled'];589590 connectedCallback() {591 this.render();592 }593594 attributeChangedCallback() {595 this.render();596 }597598 render() {599 const variant = this.getAttribute('variant') || 'primary';600 const size = this.getAttribute('size') || 'md';601 const loading = this.hasAttribute('loading');602 const disabled = this.hasAttribute('disabled');603604 this.setAttribute('role', 'button');605 this.setAttribute('tabindex', disabled ? '-1' : '0');606 this.setAttribute('aria-busy', String(loading));607 this.className = `ds-button ds-button--${variant} ds-button--${size} ${loading ? 'ds-button--loading' : ''}`;608609 if (loading) {610 const spinner = document.createElement('ds-spinner');611 spinner.setAttribute('size', size);612 this.replaceChildren(spinner);613 } else {614 this.replaceChildren(document.createElement('slot'));615 }616 }617}618619customElements.define('ds-button', DsButton);620</script>621```622623### Phase 7: CSS Architecture Selection624625Choose and apply the appropriate CSS strategy based on the project context.626627| Approach | Best For | Trade-offs |628|----------|----------|------------|629| **CSS Modules** | Component-heavy apps with scoping needs. Pairs well with React, Vue, Svelte. | No global utilities. Need separate global stylesheet for resets/base. |630| **Tailwind CSS** | Rapid prototyping, utility-first teams, consistent design tokens. | HTML verbosity. Learning curve. Heavier HTML markup. |631| **styled-components** | CSS-in-JS with dynamic theming. React-centric. | Runtime overhead. Bundle size. Harder to extract critical CSS. |632| **Vanilla CSS Custom Properties** | Framework-agnostic, design systems, web components. | No scoping built-in. Requires naming conventions (BEM). |633| **Sass/SCSS** | Teams with SCSS legacy, complex mixin/functions needs. | Compilation step. Can produce bloated output without discipline. |634| **CSS-in-JS (zero-runtime)** | Static extraction (Vanilla Extract, Panda CSS, Linaria). | Build-time dependency. Smaller ecosystem than runtime CSS-in-JS. |635636**Decision matrix:**6371. **If the project already uses a CSS approach**, match it. Consistency > personal preference.6382. **If starting fresh and speed matters**, Tailwind CSS or plain CSS custom properties.6393. **If building a design system**, CSS custom properties + CSS Modules for components.6404. **If heavy runtime theming is needed**, styled-components or Theme UI.641642### Phase 8: Visual Regression Testing Strategy6436441. **Set up a visual testing tool** — Chromatic (Storybook), Percy, Playwright645 screenshot comparison, or BackstopJS.6466472. **Define test scenarios:**648 - Every component in every meaningful state (default, hover, focus, etc.)649 - Every breakpoint650 - Every theme variant (light/dark)651 - Edge cases: very long text, missing images, empty states, error states6526533. **Capture baselines** from the initial implementation and compare against654 design references (Figma exports, design screenshots).6556564. **Establish a regression workflow:**657 ```658 Implement → Capture baseline → Compare to design → Fix diffs → Re-capture659 ```6606615. **Example Playwright visual test:**662 ```typescript663 import { test, expect } from '@playwright/test';664665 test('Button component matches design', async ({ page }) => {666 await page.goto('/components/button');667 await expect(page.locator('[data-testid="button-primary"]')).toHaveScreenshot(668 'button-primary.png',669 { maxDiffPixelRatio: 0.01 }670 );671 });672 ```6736746. **Acceptable diff thresholds:**675 - **Pixel-perfect**: 0% diff (brand pages, landing pages, core UI)676 - **Near-perfect**: <0.5% diff (internal tools, dashboards)677 - **Tolerance**: <2% diff (rapid prototyping, early-stage products)678679### Phase 9: Design System Integration680681When the project has an existing design system, integrate without disruption.6826831. **Audit the existing system** — what tokens, components, and patterns684 already exist?6856862. **Map new design elements to existing tokens:**687 - If the design uses a color that matches `--color-primary-500`, use it.688 - If the design introduces a new color not in the system, flag it:689 "This design specifies `#7C3AED` which is not in our design system.690 The closest existing token is `--color-secondary-600` (`#7C3AED` is691 an exact match to our secondary-600 — recommend using it)."6926933. **Extend components rather than creating duplicates.** If a `Card`694 component exists but the design needs a slightly different variant,695 add a prop rather than creating `SpecialCard`.6966974. **If the design contradicts the design system**, flag the discrepancy698 and ask whether the design should change or the design system should699 be updated.7007015. **Token synchronization** — If the project has a token pipeline (e.g.,702 Style Dictionary → CSS + JS + Tailwind config), update the source of703 truth, not the generated files.704705---706707## Safety Rules708709**ABSOLUTE RULES — never violate these:**7107111. **Respect intellectual property.** Never reproduce copyrighted designs,712 illustrations, logos, or brand assets without explicit permission or713 license. If a user provides a design from Dribbble, Behance, or a714 competitor's website and asks you to clone it, refuse: "I cannot715 reproduce this design because it appears to be copyrighted/owned by716 [entity]. I can help you create an original design inspired by UI717 patterns but not a direct copy."7187192. **Never ship hardcoded secrets.** If a design includes API keys,720 tokens, or credentials in code examples, flag them and strip them.721 Use environment variables.7227233. **Always use HTTPS** for external assets (fonts, images, CDN resources).724 Mixed content is a security risk.7257264. **Respect user privacy.** Don't add third-party trackers, analytics,727 or telemetry to generated code without the user's explicit request.728 Screen readers and accessibility tools must not be blocked.7297305. **Be honest about fidelity.** When working from a screenshot (not a731 design file), preface output with: "I'm working from a screenshot,732 so colors and exact measurements are approximate. Please verify733 the following values against your design spec."7347356. **Don't silently replace the design intent.** If the design has a736 complex interaction that would be expensive to implement, don't737 simplify it without asking. Say: "This carousel pattern would take738 ~4 hours to implement with full accessibility. A simpler tabbed739 layout would take ~1 hour. Which do you prefer?"7407417. **Accessibility is non-negotiable.** Every implementation must meet742 WCAG 2.1 AA at minimum. If the user explicitly asks to skip743 accessibility, warn them but comply with the caveat noted.7447458. **Don't generate inaccessibly.** Never produce code with `outline: none`746 without a replacement focus indicator. Never use `tabindex` values747 greater than 0. Never skip heading levels or use non-semantic markup748 where semantic elements exist.749750---751752## Platform Compatibility Notes753754This skill is designed to work across AI coding platforms with minor755adaptations:756757| Platform | Notes |758|----------|-------|759| **Claude Code** | Figma API integration works well. Can parse design JSON. Good for token extraction pipelines. |760| **Codex (OpenAI)** | Strong at component generation. Paste design specs or describe the design verbally. Screenshot analysis works well. |761| **Cursor** | Can read existing codebase for design system context. File system access helps with token integration. |762| **Gemini CLI** | Large context window useful for ingesting full design specs. Use `web_fetch` for Figma API. |763| **OpenClaw** | Exec for Figma CLI/API calls. GitHub skill for PR-based design review. Image analysis for screenshots. |764| **GitHub Copilot** | Works within IDE context. Best for incremental component implementation with existing design system access. |765| **Windsurf** | Can access workspace files and design assets. Execute design-to-code in context of existing project. |766| **OpenCode** | Terminal-based. Best with explicit design specs pasted or described textually. Can run token extraction scripts. |767768### Platform-Specific Adjustments769770- **If Figma API token is unavailable**: ask the user to export the design as771 SVG/PNG or paste a design spec document. Screenshot analysis is the fallback.772- **If image/vision analysis is not available**: ask the user to describe the773 design in text (layout, colors, typography, spacing). Work from description.774- **If a specific framework is not specified**: default to the framework the775 project already uses. If no project exists, ask the user.776- **For Discord/Slack delivery**: use bullet lists, not markdown tables. Split777 large code blocks across multiple messages. Wrap links in `<>`.778- **For platforms without file system access**: inline tokens and styles779 directly in generated output rather than referencing external files.780781---782783## References784785- `references/design-tokens-guide.md` — W3C Design Tokens Community Group786 specification and implementation guide787- [WCAG 2.1 Quick Reference](https://www.w3.org/WAI/WCAG21/quickref/) —788 Official WCAG 2.1 guidelines789- [WAI-ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/) —790 ARIA design patterns and widget examples791- [Figma API Documentation](https://www.figma.com/developers/api) —792 Figma REST API reference793- [Style Dictionary](https://amzn.github.io/style-dictionary/) —794 Design token transformation tool795- [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/) —796 Color contrast verification797- [axe DevTools](https://www.deque.com/axe/) — Automated accessibility testing798- [Chromatic](https://www.chromatic.com/) — Visual regression testing for799 Storybook
Run npx skillmds@latest add jpeetz/design-to-code in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Use this skill when translating UI/UX designs into production-ready frontend code. Handles design source ingestion (Figma, Sketch, Adobe XD, screenshots, design specs), design token extraction, component hierarchy mapping, responsive breakpoint strategy, accessibility-first implementation (WCAG 2.1 AA minimum), framework-agnostic patterns (React, Vue, Svelte, plain HTML/CSS), design system integration, visual regression testing, and CSS architecture selection (CSS Modules, Tailwind, styled-components). Primary keyword clusters: design to code conversion, figma to react, design token extraction, UI component architecture, accessibility implementation WCAG, responsive design breakpoints, pixel perfect implementation, design system integration, CSS architecture patterns, visual regression testing strategy. Designed for agentic platforms — Claude Code, Codex, Cursor, Gemini CLI, OpenClaw, GitHub Copilot, Windsurf, and OpenCode. It is listed under Design & Media on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
JPeetz (@jpeetz) published this skill. Their other Agent Skills are listed on their SkillMD profile.