Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计提醒

figma-to-react-componentsFigma TO React 组件

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

524

周安装

21

GitHub Stars

13

下载量

170
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:figma-to-react-components(Figma TO React 组件)
来源仓库:https://github.com/ravnhq/ai-toolkit
仓库路径:skills/figma-to-react-components
安装命令:
npx skills add https://github.com/ravnhq/ai-toolkit --skill figma-to-react-components
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/ravnhq/ai-toolkit --skill figma-to-react-components

简介

用于辅助前端页面和组件开发,支持 React、Next.js、Vue 等框架代码生成。

  • 可审查样式、布局和交互逻辑,帮助定位性能问题和组件结构问题。
  • 需结合项目现有设计系统和路由方式,避免生成孤立片段影响整体一致性。
  • 安装方式:github,命令为 npx skills add https://github.com/ravnhq/ai-toolkit --skill figma-to-react-components。
  • 注意:页面改动后应通过本地预览和构建检查确认视觉效果和兼容性。

SKILL.md

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 Ariareact-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:

  1. 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.

  1. Component output directory — Where components live (e.g., src/components/)
  2. Stories directory — Where Storybook stories live (e.g., stories/ or co-located)
  3. Styling approach — SCSS modules, CSS modules, Tailwind utility classes, styled-components, etc.
  4. 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:

  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):

  • 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:

  1. Props Documentation ([ComponentName]-props.md)

- All tokens referenced by variable name - Complete accessibility documentation

  1. React Component ([ComponentName].tsx)

- TypeScript with full type safety - React Aria integration - No inline SVG code — use project's icon library

  1. Styles ([ComponentName].[scss|module.scss|css])

- Token-based styling - BEM methodology - All state variants

  1. 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

  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.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.5%
按下载量换算64

Claude

29.46%
按下载量换算50

Cursor

20.93%
按下载量换算36

Gemini CLI

8.93%
按下载量换算15

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills