Loading...
Loading...
Figma-to-code design handoff patterns including Figma Variables to design tokens pipeline, component spec extraction, Dev Mode inspection, Auto Layout to CSS Flexbox/Grid mapping, and visual regression with Applitools. Use when converting Figma designs to code, documenting component specs, setting up design-dev workflows, or comparing production UI against Figma designs.
npx skill4agent add yonatangross/orchestkit figma-design-handoff| Rule | File | Impact | When to Use |
|---|---|---|---|
| Figma Variables & Tokens | | CRITICAL | Converting Figma Variables to W3C design tokens JSON |
| Component Specs | | HIGH | Extracting component props, variants, states from Figma |
| Dev Mode Inspection | | HIGH | Measurements, spacing, typography, asset export |
| Auto Layout → CSS | | HIGH | Mapping Auto Layout to Flexbox/Grid |
| Visual Regression | | MEDIUM | Comparing production UI against Figma designs |
# 1. Export Figma Variables → tokens.json (using Figma REST API)
curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
"https://api.figma.com/v1/files/$FILE_KEY/variables/local" \
| node scripts/figma-to-w3c-tokens.js > tokens/figma-raw.json
# 2. Transform with Style Dictionary
npx style-dictionary build --config sd.config.js
# 3. Output: CSS custom properties + Tailwind theme
# tokens/
# figma-raw.json ← W3C Design Tokens format
# css/variables.css ← --color-primary: oklch(0.65 0.15 250);
# tailwind/theme.js ← module.exports = { colors: { primary: ... } }// W3C Design Tokens Format (DTCG)
{
"color": {
"primary": {
"$type": "color",
"$value": "{color.blue.600}",
"$description": "Primary brand color"
},
"surface": {
"$type": "color",
"$value": "{color.neutral.50}",
"$extensions": {
"mode": {
"dark": "{color.neutral.900}"
}
}
}
}
}// Style Dictionary config for Figma Variables
import StyleDictionary from 'style-dictionary';
export default {
source: ['tokens/figma-raw.json'],
platforms: {
css: {
transformGroup: 'css',
buildPath: 'tokens/css/',
files: [{ destination: 'variables.css', format: 'css/variables' }],
},
tailwind: {
transformGroup: 'js',
buildPath: 'tokens/tailwind/',
files: [{ destination: 'theme.js', format: 'javascript/module' }],
},
},
};┌─────────────┐ ┌──────────────┐ ┌───────────────┐
│ Figma File │────▶│ Dev Mode │────▶│ tokens.json │
│ (Variables, │ │ (Inspect, │ │ (W3C DTCG │
│ Auto Layout)│ │ Export) │ │ format) │
└─────────────┘ └──────────────┘ └───────┬───────┘
│
▼
┌─────────────┐ ┌──────────────┐ ┌───────────────┐
│ Visual QA │◀────│ Components │◀────│ Style │
│ (Applitools,│ │ (React + │ │ Dictionary │
│ Chromatic) │ │ Tailwind) │ │ (CSS/Tailwind)│
└─────────────┘ └──────────────┘ └───────────────┘rules/| Figma Auto Layout | CSS Equivalent | Tailwind Class |
|---|---|---|
| Direction: Horizontal | | |
| Direction: Vertical | | |
| Gap: 16 | | |
| Padding: 16 | | |
| Padding: 16, 24 | | |
| Align: Center | | |
| Justify: Space between | | |
| Fill container | | |
| Hug contents | | |
| Fixed width: 200 | | |
| Min width: 100 | | |
| Max width: 400 | | |
| Wrap | | |
| Absolute position | | |
// Applitools Eyes + Figma Plugin — CI integration
import { Eyes, Target } from '@applitools/eyes-playwright';
const eyes = new Eyes();
await eyes.open(page, 'MyApp', 'Homepage — Figma Comparison');
// Capture full page
await eyes.check('Full Page', Target.window().fully());
// Capture specific component
await eyes.check(
'Hero Section',
Target.region('#hero').ignoreDisplacements()
);
await eyes.close();| Decision | Recommendation |
|---|---|
| Token format | W3C Design Tokens Community Group (DTCG) JSON |
| Token pipeline | Figma REST API → Style Dictionary → CSS/Tailwind |
| Color format | OKLCH for perceptually uniform theming |
| Layout mapping | Auto Layout → CSS Flexbox (Grid for 2D layouts) |
| Visual QA tool | Applitools Eyes + Figma Plugin for design-dev diff |
| Spec format | TypeScript interfaces matching Figma component props |
| Mode handling | Figma Variable modes → CSS media queries / class toggles |
| Resource | Description |
|---|---|
| references/figma-to-code-workflow.md | End-to-end workflow, toolchain options |
| references/design-dev-communication.md | PR templates, component status tracking |
| references/applitools-figma-plugin.md | Setup, CI integration, comparison config |
ork:design-system-tokensork:ui-componentsork:accessibility