사용 방법
- 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
- 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
- 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/southleft/skills-for-figma --skill analyze-component-set-figma시작 전 확인
- 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
- 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.
analyze-component-set-figma — variant state machine → CSS
Take a Figma COMPONENT_SET (the purple dashed container holding all the variants of one component) and turn it into a code-generation blueprint: which property axes are state vs size, how each state maps to a CSS pseudo-class or ARIA attribute, and the minimal visual delta each state applies on top of the default variant. This is the bridge between "Figma has 12 button variants" and "emit one .btn rule + :hover/:disabled overrides."
Skill boundaries
- `use_figma` rules — load the official `figma-use` skill first; it is the full Figma Plugin API reference. Essentials these scripts rely on: plain JS with top-level
await+return(no IIFE, nofigma.closePlugin();console.logis not returned), inputs inlined asconstat the top of each script, colors in 0–1 range, load fonts before any text op,await figma.getNodeByIdAsync(...), and atomic errors (a failed script applies nothing — read the error, fix, retry). - Full recursive tree (unlimited depth, reactions, instance refs) → use
deep-component-figma. - Reorganizing variants into a labeled grid → use
arrange-component-set-figma. - Adding/removing the properties themselves → use
component-properties-figma. - This is a design-system code-gen capability that the native MCP's
get_design_context/
get_metadata do not provide — they return raw structure, not a variant→CSS state machine.
Workflow
- Get the COMPONENT_SET id. From the user's selection (
figma_get_selection), a search, or a
node id they paste. It must be the set, not an individual variant — the script validates type.
- Run `scripts/analyze-component-set.js` via
use_figma
(skillNames: "analyze-component-set-figma"). Set const COMPONENT_SET_ID at the top first.
- Read the result. It returns
variantAxes(each axis + its options),componentProps
(non-variant TEXT/BOOLEAN/INSTANCE_SWAP props → code props), a stateMachine with cssMapping (state name → CSS selector) and defaultSignature, and per-variant diffFromDefault.
- Generate code. Implement the default variant from
defaultSignature, then add one rule per
cssMapping entry applying only that variant's diffFromDefault. Map componentProps to framework props: BOOLEAN→boolean, TEXT→string, INSTANCE_SWAP→ReactNode/slot, VARIANT→union.
- Validate. Cross-check that every state in
stateMachine.statesgot a CSS rule, and that
token names in the diff (e.g. Color/Brand/Primary) resolve to your exported tokens.
How states map to CSS
The script normalizes the state axis value (case-insensitive) to a selector:
| Variant value | CSS / ARIA selector | |
|---|---|---|
default | (base rule, no selector) | |
hover | :hover | |
focus / focused / focus-visible | :focus-visible | |
active / pressed | :active | |
disabled | :disabled, [aria-disabled="true"] | |
error / invalid | [aria-invalid="true"] | |
selected | [aria-selected="true"] | |
checked | :checked | |
loading | [aria-busy="true"] | |
open / closed | `[aria-expanded="true" | "false"]` |
filled | .has-value |
Notes
- Diffs are computed against the default variant, so a state's
diffFromDefaultlists only the
properties that change (fill token, stroke, text color, opacity, effects, child visibility). Emit exactly those as overrides — don't re-specify unchanged properties.
- The script resolves
boundVariables(fills/strokes) to token names when available, falling
back to raw hex. Prefer the token name in generated code.
- Axis detection is heuristic: an axis named
state/status/interactionis the state axis;
size/scale is the size axis. If your set names axes differently, the cssMapping may be empty — read variantAxes and map states yourself.


