Figma to react components

From ravnhq/ai-toolkit · View interactive version

Figma to react components is an AI agent skill from the GitHub repository ravnhq/ai-toolkit. 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-developmen

How to use this skill

Skill file

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

Project Configuration Discovery

On first use in a project, discover the local configuration before generating code. Search the codebase to determine:

  1. Token import path — Where tokens are imported from. Search for existing token files:
  1. Component output directory — Where components live (e.g., src/components/)
  1. Stories directory — Where Storybook stories live (e.g., stories/ or co-located)
  1. Styling approach — SCSS modules, CSS modules, Tailwind utility classes, styled-components, etc.
  1. 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:

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:

  1. Use get_variable_defs to pull all variable collections from the Figma file
  2. Ask the user for their preferred format (SCSS, CSS custom properties, or Tailwind) and output directory
  3. Generate organized token files (colors, spacing, typography, radius, elevation) using semantic naming conventions
  4. Create an index/barrel file that imports all token partials
  5. Proceed with mapping component values to the newly generated tokens

Token categories to map (or generate):

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:

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:

Phase 5: Generate Styles

Create the stylesheet using the project's token system.

Structure:

Phase 6: Create Storybook Story

Generate Storybook documentation showing all variants:

Phase 7: Testing & Validation

After implementation, validate:

Phase 8: Cleanup Junk Files

The Figma MCP sometimes generates temporary files during extraction:

Output Structure

Deliver all artifacts in this order:

  1. Props Documentation ([ComponentName]-props.md)
  1. React Component ([ComponentName].tsx)
  1. Styles ([ComponentName].[scss|module.scss|css])
  1. Storybook Story ([ComponentName].stories.tsx)

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

React Aria Hook Selection Unclear

Generated Styles Use Raw Values

Component Props Do Not Match Figma

Workflow

  1. Identify whether the request matches a Figma-to-React conversion task.
  2. Follow the 8-phase workflow: extract design context, map tokens, generate props docs, build component, create styles, write story, validate, clean up.
  3. Verify all output uses project tokens (no hardcoded values) and includes React Aria accessibility.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.