--- id: wiki-2026-0508-figma-integration title: Figma Integration category: 10_Wiki/Topics status: verified canonical_id: self aliases: [Figma API, Figma plugin, design tokens, Figma to code, Dev Mode, AI Figma] duplicate_of: none source_trust_level: A confidence_score: 0.94 verification_status: applied tags: [figma, design-system, design-tokens, plugin, dev-mode, ai-design] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: TypeScript / JavaScript framework: Figma Plugin API / REST API / Dev Mode --- # Figma Integration ## 매 한 줄 > **"매 Figma 의 의 의 design 의 code / system 의 connect"**. 매 REST API + 매 Plugin API + 매 Dev Mode + 매 Variables (design tokens). 매 modern: 매 AI 매 (Anima, Builder.io, Locofy) figma → React. ## 매 핵심 ### 매 API surface - **REST**: 매 read file structure. - **Plugin API**: 매 in-Figma scripting. - **Webhook**: 매 file 의 변화 의 react. - **Variables API** (2024+): 매 design tokens. - **Dev Mode**: 매 inspection + token reference. ### 매 응용 1. **Design tokens**: 매 Figma → CSS / Tailwind. 2. **Code generation**: 매 React / SwiftUI. 3. **Documentation**: 매 component → Storybook. 4. **Localization**: 매 string export. 5. **Asset export**: 매 SVG / PNG / icons. 6. **AI prompt**: 매 design → spec. ### 매 modern AI tool - **Anima**: 매 figma → React/Vue. - **Builder.io Visual Copilot**: 매 figma + AI. - **Locofy.ai**. - **FigJam AI**. - **Magic Patterns**: 매 design → component. ## 💻 패턴 ### REST API (read file) ```typescript async function getFigmaFile(fileKey: string, token: string) { const r = await fetch(`https://api.figma.com/v1/files/${fileKey}`, { headers: { 'X-Figma-Token': token }, }); return r.json(); } ``` ### Variables API (design tokens) ```typescript async function getVariables(fileKey: string, token: string) { const r = await fetch(`https://api.figma.com/v1/files/${fileKey}/variables/local`, { headers: { 'X-Figma-Token': token }, }); return r.json(); } // 매 transform → CSS variables function variablesToCss(variables: any[]): string { return variables.map(v => `--${v.name}: ${v.value};`).join('\n'); } ``` ### Plugin (TS, manifest.json) ```json { "name": "Token Sync", "id": "1234", "api": "1.0.0", "main": "code.js", "ui": "ui.html", "editorType": ["figma"] } ``` ### Plugin script (sync tokens) ```typescript // 매 code.ts figma.showUI(__html__, { width: 320, height: 480 }); figma.ui.onmessage = async msg => { if (msg.type === 'export-tokens') { const collections = await figma.variables.getLocalVariableCollectionsAsync(); const tokens: any = {}; for (const c of collections) { tokens[c.name] = {}; for (const id of c.variableIds) { const v = await figma.variables.getVariableByIdAsync(id); tokens[c.name][v.name] = v.valuesByMode; } } figma.ui.postMessage({ type: 'tokens', data: tokens }); } }; ``` ### Token JSON (design tokens W3C) ```json { "color": { "primary": { "$value": "#3b82f6", "$type": "color" }, "danger": { "$value": "#ef4444", "$type": "color" } }, "spacing": { "sm": { "$value": "8px", "$type": "dimension" }, "md": { "$value": "16px", "$type": "dimension" } } } ``` ### Style Dictionary (Amazon) ```javascript // 매 figma → JSON → all platforms const StyleDictionary = require('style-dictionary').extend({ source: ['tokens.json'], platforms: { css: { transformGroup: 'css', files: [{ destination: 'tokens.css', format: 'css/variables' }] }, ios: { transformGroup: 'ios-swift', files: [{ destination: 'Tokens.swift', format: 'ios-swift/class.swift' }] }, android: { transformGroup: 'android', files: [{ destination: 'colors.xml', format: 'android/colors' }] }, }, }); StyleDictionary.buildAllPlatforms(); ``` ### Figma to React (Anima-style) ```python def figma_to_react(figma_node): """매 simplified.""" if figma_node.type == 'FRAME': return f"