Figma to React Component Converter
Convert Figma component designs into production-ready React components with full design token integration, accessibility support via React Aria, and comprehensive documentation. Works with any design token system (SCSS variables, CSS custom properties, Tailwind, or JavaScript tokens).
Prerequisites
- Figma MCP — Figma MCP server configured and running
- React Aria —
react-aria and react-stately installed
- Design tokens (optional) — If the project already has a token system (SCSS, CSS vars, Tailwind, JS/TS), map to it. If not, tokens are extracted from Figma and generated as part of the workflow.
- Storybook (optional) — For component documentation and visual testing
Project Configuration Discovery
On first use in a project, discover the local configuration before generating code. Search the codebase to determine:
Token import path — Where tokens are imported from. Search for existing token files:
- SCSS:
@import 'styles/tokens' or @import 'path/to/variables'
- CSS:
@import 'tokens.css' or custom properties in :root
- Tailwind:
tailwind.config.ts theme extension
- JS/TS:
import { tokens } from './tokens'
- If no token files exist: Tokens will be extracted from Figma and generated during Phase 2. Ask the user which format to generate (SCSS, CSS custom properties, or Tailwind) and where to save them.
Component output directory — Where components live (e.g., src/components/)
Stories directory — Where Storybook stories live (e.g., stories/ or co-located)
Styling approach — SCSS modules, CSS modules, Tailwind utility classes, styled-components, etc.
Icon/asset strategy — Project icon library location and import convention
Cache these findings for the session. If unsure about any setting, ask the user before generating code.
Workflow
Follow these phases in order:
Phase 1: Extract Figma Design Context
Use Figma MCP tools to gather component information:
Figma:get_design_context(fileKey, nodeId) # Component structure and tokens
Figma:get_variable_defs(fileKey, nodeId) # Variable definitions for token mapping
Figma:get_screenshot(fileKey, nodeId) # Visual reference
What to extract:
- Component structure and hierarchy
- Applied variables/tokens (colors, spacing, typography)
- Variant properties (size, state, hierarchy)
- Interactive states (hover, pressed, disabled, focus)
- Text styles and their token mappings
- Layout constraints and spacing values
- Icons and image fills
Phase 2: Map Design Tokens
If the project has existing tokens: Cross-reference Figma variables to the project's token system using references/token-mapping-guide.md.
If the project has NO token files: Extract tokens directly from Figma and generate token files. See references/token-mapping-guide.md § "Extracting Tokens from Figma" for the full workflow:
- Use
get_variable_defs to pull all variable collections from the Figma file
- Ask the user for their preferred format (SCSS, CSS custom properties, or Tailwind) and output directory
- Generate organized token files (colors, spacing, typography, radius, elevation) using semantic naming conventions
- Create an index/barrel file that imports all token partials
- Proceed with mapping component values to the newly generated tokens
Token categories to map (or generate):
- Colors (backgrounds, text, borders, icons)
- Spacing (padding, margins, gaps)
- Typography (font family, size, weight, line height)
- Border radius
- Elevation/shadows
- Component sizes (heights, widths, icon sizes)
Important: Use the project's token variable names, never raw values (see rules/tokens-never-hardcode.md).
Phase 3: Generate Props Documentation
Create props documentation following references/props-template.md.
Required sections:
- Overview (max 200 characters)
- Component Properties (Props table + React Aria Properties table)
- Size Variants (using typography token names)
- Hierarchy Variants
- State Variants (default, hover, pressed, disabled, focus)
- Icons (token references for icon sizes)
- Typography (token names from Figma descriptions)
- Accessibility (Focus State, Keyboard Navigation, Disabled State, Color Contrast)
- Usage Guidelines
Prop naming: Follow conventions in references/figma-property-conventions.md.
Phase 4: Generate React Component Code
Create the component following references/component-patterns.md.
Requirements:
- React Aria hooks for accessibility (see
rules/aria-use-react-aria-hooks.md)
- TypeScript with explicit prop interfaces
- BEM naming convention for CSS classes (see
rules/naming-bem-methodology.md)
- Proper disabled state handling
- Focus management with
:focus-visible (see rules/aria-focus-visible-only.md)
- Build props from actual Figma MCP extraction, not assumptions
Phase 5: Generate Styles
Create the stylesheet using the project's token system.
Structure:
- Import tokens from the discovered project path
- Base styles using token references
- State modifiers (
:hover, :active, :disabled, :focus-visible)
- Size variant modifiers
- Hierarchy/variant modifiers
- Use semantic token names (see
rules/tokens-use-semantic-names.md)
Phase 6: Create Storybook Story
Generate Storybook documentation showing all variants:
- Default story with primary args
- Size variants side by side
- Hierarchy/visual variants
- State demonstrations (default, disabled)
- Include React Aria prop controls (
aria-label, aria-labelledby, aria-describedby)
Phase 7: Testing & Validation
After implementation, validate:
- Visual comparison with Figma design (within 2px tolerance)
- All variants render correctly
- Interactive states (hover, focus, pressed, disabled) work as expected
- Keyboard navigation functions properly
- No hardcoded values remain — all visual properties use tokens
Phase 8: Cleanup Junk Files
The Figma MCP sometimes generates temporary files during extraction:
- Remove root-level SVG files generated by Figma MCP
- Remove temporary images not in project asset directories
- Verify no orphaned files from the MCP extraction process
Output Structure
Deliver all artifacts in this order:
Props Documentation ([ComponentName]-props.md)
- All tokens referenced by variable name
- Complete accessibility documentation
React Component ([ComponentName].tsx)
- TypeScript with full type safety
- React Aria integration
- No inline SVG code — use project's icon library
Styles ([ComponentName].[scss|module.scss|css])
- Token-based styling
- BEM methodology
- All state variants
Storybook Story ([ComponentName].stories.tsx)
- Interactive examples with React Aria props
- All variants demonstrated
Rules
See rules index for token, accessibility, and naming rules.
Examples
Positive Trigger
User: "Convert this Figma button component to React with all its variants and states."
Expected behavior: Use figma-to-react-components guidance — extract Figma context via MCP, map tokens, generate typed React component with React Aria, create styles using project tokens, and produce Storybook story.
Non-Trigger
User: "Write unit tests for this payment service."
Expected behavior: Do not prioritize figma-to-react-components; choose a more relevant skill or proceed without it.
Troubleshooting
Figma Tokens Not Found
- Error: Figma variables do not map to any project tokens.
- Cause: Token variable names in Figma differ from project token names, token files are in an unexpected location, or the project has no token files yet.
- Solution: First search the codebase for token files. If found, map Figma variable names to project token names using
references/token-mapping-guide.md. If no token files exist, extract tokens from Figma using get_variable_defs and generate token files — see references/token-mapping-guide.md § "Extracting Tokens from Figma".
React Aria Hook Selection Unclear
- Error: Unsure which React Aria hook to use for a given component.
- Cause: Component type does not match a standard pattern (Button, TextField, Select, etc.).
- Solution: Check the React Aria hooks table in
rules/aria-use-react-aria-hooks.md. For complex components, compose multiple hooks or use useFocusRing as a baseline.
Generated Styles Use Raw Values
- Error: Component styles contain hardcoded pixel values or hex colors instead of tokens.
- Cause: Token mapping was skipped or incomplete during Phase 2.
- Solution: Re-run token mapping against the project's token system. Replace every raw value with its token reference. If no token exists, flag it as a gap with a
/* TODO */ comment.
Component Props Do Not Match Figma
- Error: Generated React props do not align with Figma component properties.
- Cause: Props were assumed instead of extracted from Figma MCP.
- Solution: Re-extract using
get_design_context and rebuild props from actual Figma component definitions. Follow naming conventions in references/figma-property-conventions.md.
Workflow
- Identify whether the request matches a Figma-to-React conversion task.
- Follow the 8-phase workflow: extract design context, map tokens, generate props docs, build component, create styles, write story, validate, clean up.
- Verify all output uses project tokens (no hardcoded values) and includes React Aria accessibility.
1---2name: figma-to-react-components3description: Convert Figma component designs into production-ready React implementations with design token integration, accessibility via React Aria, and comprehensive documentation. Use when building React components from Figma designs, generating component implementation specs, or bridging design-to-development workflows.4---56# Figma to React Component Converter78Convert Figma component designs into production-ready React components with full design token integration, accessibility support via React Aria, and comprehensive documentation. Works with any design token system (SCSS variables, CSS custom properties, Tailwind, or JavaScript tokens).910## Prerequisites1112- **Figma MCP** — Figma MCP server configured and running13- **React Aria** — `react-aria` and `react-stately` installed14- **Design tokens** (optional) — If the project already has a token system (SCSS, CSS vars, Tailwind, JS/TS), map to it. If not, tokens are extracted from Figma and generated as part of the workflow.15- **Storybook** (optional) — For component documentation and visual testing1617## Project Configuration Discovery1819On first use in a project, discover the local configuration before generating code. Search the codebase to determine:20211. **Token import path** — Where tokens are imported from. Search for existing token files:22 - SCSS: `@import 'styles/tokens'` or `@import 'path/to/variables'`23 - CSS: `@import 'tokens.css'` or custom properties in `:root`24 - Tailwind: `tailwind.config.ts` theme extension25 - JS/TS: `import { tokens } from './tokens'`26 - **If no token files exist:** Tokens will be extracted from Figma and generated during Phase 2. Ask the user which format to generate (SCSS, CSS custom properties, or Tailwind) and where to save them.27282. **Component output directory** — Where components live (e.g., `src/components/`)29303. **Stories directory** — Where Storybook stories live (e.g., `stories/` or co-located)31324. **Styling approach** — SCSS modules, CSS modules, Tailwind utility classes, styled-components, etc.33345. **Icon/asset strategy** — Project icon library location and import convention3536Cache these findings for the session. If unsure about any setting, ask the user before generating code.3738## Workflow3940Follow these phases in order:4142### Phase 1: Extract Figma Design Context4344Use Figma MCP tools to gather component information:4546```47Figma:get_design_context(fileKey, nodeId) # Component structure and tokens48Figma:get_variable_defs(fileKey, nodeId) # Variable definitions for token mapping49Figma:get_screenshot(fileKey, nodeId) # Visual reference50```5152**What to extract:**53- Component structure and hierarchy54- Applied variables/tokens (colors, spacing, typography)55- Variant properties (size, state, hierarchy)56- Interactive states (hover, pressed, disabled, focus)57- Text styles and their token mappings58- Layout constraints and spacing values59- Icons and image fills6061### Phase 2: Map Design Tokens6263**If the project has existing tokens:** Cross-reference Figma variables to the project's token system using `references/token-mapping-guide.md`.6465**If the project has NO token files:** Extract tokens directly from Figma and generate token files. See `references/token-mapping-guide.md` § "Extracting Tokens from Figma" for the full workflow:661. Use `get_variable_defs` to pull all variable collections from the Figma file672. Ask the user for their preferred format (SCSS, CSS custom properties, or Tailwind) and output directory683. Generate organized token files (colors, spacing, typography, radius, elevation) using semantic naming conventions694. Create an index/barrel file that imports all token partials705. Proceed with mapping component values to the newly generated tokens7172**Token categories to map (or generate):**73- Colors (backgrounds, text, borders, icons)74- Spacing (padding, margins, gaps)75- Typography (font family, size, weight, line height)76- Border radius77- Elevation/shadows78- Component sizes (heights, widths, icon sizes)7980**Important:** Use the project's token variable names, never raw values (see `rules/tokens-never-hardcode.md`).8182### Phase 3: Generate Props Documentation8384Create props documentation following `references/props-template.md`.8586**Required sections:**87- Overview (max 200 characters)88- Component Properties (Props table + React Aria Properties table)89- Size Variants (using typography token names)90- Hierarchy Variants91- State Variants (default, hover, pressed, disabled, focus)92- Icons (token references for icon sizes)93- Typography (token names from Figma descriptions)94- Accessibility (Focus State, Keyboard Navigation, Disabled State, Color Contrast)95- Usage Guidelines9697**Prop naming:** Follow conventions in `references/figma-property-conventions.md`.9899### Phase 4: Generate React Component Code100101Create the component following `references/component-patterns.md`.102103**Requirements:**104- React Aria hooks for accessibility (see `rules/aria-use-react-aria-hooks.md`)105- TypeScript with explicit prop interfaces106- BEM naming convention for CSS classes (see `rules/naming-bem-methodology.md`)107- Proper disabled state handling108- Focus management with `:focus-visible` (see `rules/aria-focus-visible-only.md`)109- Build props from actual Figma MCP extraction, not assumptions110111### Phase 5: Generate Styles112113Create the stylesheet using the project's token system.114115**Structure:**116- Import tokens from the discovered project path117- Base styles using token references118- State modifiers (`:hover`, `:active`, `:disabled`, `:focus-visible`)119- Size variant modifiers120- Hierarchy/variant modifiers121- Use semantic token names (see `rules/tokens-use-semantic-names.md`)122123### Phase 6: Create Storybook Story124125Generate Storybook documentation showing all variants:126- Default story with primary args127- Size variants side by side128- Hierarchy/visual variants129- State demonstrations (default, disabled)130- Include React Aria prop controls (`aria-label`, `aria-labelledby`, `aria-describedby`)131132### Phase 7: Testing & Validation133134After implementation, validate:135- Visual comparison with Figma design (within 2px tolerance)136- All variants render correctly137- Interactive states (hover, focus, pressed, disabled) work as expected138- Keyboard navigation functions properly139- No hardcoded values remain — all visual properties use tokens140141### Phase 8: Cleanup Junk Files142143The Figma MCP sometimes generates temporary files during extraction:144- Remove root-level SVG files generated by Figma MCP145- Remove temporary images not in project asset directories146- Verify no orphaned files from the MCP extraction process147148## Output Structure149150Deliver all artifacts in this order:1511521. **Props Documentation** (`[ComponentName]-props.md`)153 - All tokens referenced by variable name154 - Complete accessibility documentation1551562. **React Component** (`[ComponentName].tsx`)157 - TypeScript with full type safety158 - React Aria integration159 - No inline SVG code — use project's icon library1601613. **Styles** (`[ComponentName].[scss|module.scss|css]`)162 - Token-based styling163 - BEM methodology164 - All state variants1651664. **Storybook Story** (`[ComponentName].stories.tsx`)167 - Interactive examples with React Aria props168 - All variants demonstrated169170## Rules171172See [rules index](rules/_sections.md) for token, accessibility, and naming rules.173174## Examples175176### Positive Trigger177178User: "Convert this Figma button component to React with all its variants and states."179180Expected behavior: Use `figma-to-react-components` guidance — extract Figma context via MCP, map tokens, generate typed React component with React Aria, create styles using project tokens, and produce Storybook story.181182### Non-Trigger183184User: "Write unit tests for this payment service."185186Expected behavior: Do not prioritize `figma-to-react-components`; choose a more relevant skill or proceed without it.187188## Troubleshooting189190### Figma Tokens Not Found191192- Error: Figma variables do not map to any project tokens.193- Cause: Token variable names in Figma differ from project token names, token files are in an unexpected location, or the project has no token files yet.194- Solution: First search the codebase for token files. If found, map Figma variable names to project token names using `references/token-mapping-guide.md`. If no token files exist, extract tokens from Figma using `get_variable_defs` and generate token files — see `references/token-mapping-guide.md` § "Extracting Tokens from Figma".195196### React Aria Hook Selection Unclear197198- Error: Unsure which React Aria hook to use for a given component.199- Cause: Component type does not match a standard pattern (Button, TextField, Select, etc.).200- Solution: Check the React Aria hooks table in `rules/aria-use-react-aria-hooks.md`. For complex components, compose multiple hooks or use `useFocusRing` as a baseline.201202### Generated Styles Use Raw Values203204- Error: Component styles contain hardcoded pixel values or hex colors instead of tokens.205- Cause: Token mapping was skipped or incomplete during Phase 2.206- Solution: Re-run token mapping against the project's token system. Replace every raw value with its token reference. If no token exists, flag it as a gap with a `/* TODO */` comment.207208### Component Props Do Not Match Figma209210- Error: Generated React props do not align with Figma component properties.211- Cause: Props were assumed instead of extracted from Figma MCP.212- Solution: Re-extract using `get_design_context` and rebuild props from actual Figma component definitions. Follow naming conventions in `references/figma-property-conventions.md`.213214## Workflow2152161. Identify whether the request matches a Figma-to-React conversion task.2172. Follow the 8-phase workflow: extract design context, map tokens, generate props docs, build component, create styles, write story, validate, clean up.2183. Verify all output uses project tokens (no hardcoded values) and includes React Aria accessibility.