figma-to-tailwind

Figma MCPで取得したデザイン変数をTailwind CSS標準クラスに変換する。Figma MCPのコード生成後やデザイン実装時に自動起動。

242 stars

Best use case

figma-to-tailwind is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. Figma MCPで取得したデザイン変数をTailwind CSS標準クラスに変換する。Figma MCPのコード生成後やデザイン実装時に自動起動。

Figma MCPで取得したデザイン変数をTailwind CSS標準クラスに変換する。Figma MCPのコード生成後やデザイン実装時に自動起動。

Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.

Practical example

Example input

Use the "figma-to-tailwind" skill to help with this workflow task. Context: Figma MCPで取得したデザイン変数をTailwind CSS標準クラスに変換する。Figma MCPのコード生成後やデザイン実装時に自動起動。

Example output

A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.

When to use this skill

  • Use this skill when you want a reusable workflow rather than writing the same prompt again and again.

When not to use this skill

  • Do not use this when you only need a one-off answer and do not need a reusable workflow.
  • Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/figma-to-tailwind/SKILL.md --create-dirs "https://raw.githubusercontent.com/aiskillstore/marketplace/main/skills/crearize/figma-to-tailwind/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/figma-to-tailwind/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How figma-to-tailwind Compares

Feature / Agentfigma-to-tailwindStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Figma MCPで取得したデザイン変数をTailwind CSS標準クラスに変換する。Figma MCPのコード生成後やデザイン実装時に自動起動。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Figma Variables → Tailwind CSS 変換スキル

このスキルは、Figma MCPで取得したデザイン変数(Variables)を、Tailwind CSS標準クラスに自動変換するためのガイドです。

## いつ使用するか

以下の状況で、このスキルを自動的に適用してください:

1. **Figma MCPでデザインを取得した後**
   - `mcp__figma-mcp__get_design_context`や`mcp__figma-mcp__get_variable_defs`を実行した直後
   - Figma MCPが生成したコードに`var(--spacing-*)`や`var(--width-*)`などの変数が含まれている場合

2. **デザイン実装中**
   - コンポーネントのスタイリング時
   - レイアウト調整時
   - Figma変数を使用しているコードを発見した場合

3. **コードレビュー時**
   - `px-[var(--spacing-4)]`のようなFigma変数の直接使用を発見した場合
   - インラインスタイルで`style={{ fontSize: 'var(--h4-font-size)' }}`のような記述を発見した場合

## 変換手順

### ステップ1: マッピングファイルを確認

`frontend/lib/figma-tailwind-map.ts`を参照して、Figma変数がTailwind標準クラスに変換可能か確認します。

```typescript
import {
  spacingMap,
  widthMap,
  heightMap,
  borderRadiusMap,
  typographyMap,
  figmaVarToTailwindClass,
  isStandardTailwindClass
} from '@/lib/figma-tailwind-map'
```

### ステップ2: 変換ルールの適用

#### スペーシング(spacing)

```typescript
// ❌ Figma MCPが生成したコード
<div className="px-[var(--spacing-4,16px)] py-[var(--spacing-2,8px)] gap-[var(--spacing-3,12px)]">

// ✅ Tailwind標準クラスに変換
<div className="px-4 py-2 gap-3">
```

**変換マッピング:**
- `spacing/1` → `1` (4px)
- `spacing/2` → `2` (8px)
- `spacing/3` → `3` (12px)
- `spacing/4` → `4` (16px)
- `spacing/1-5` → `1.5` (6px) ※カスタム
- `spacing/2-5` → `2.5` (10px) ※カスタム

#### サイズ(width/height)

```typescript
// ❌ Figma MCPが生成したコード
<div className="w-[var(--width-w-4,16px)] h-[var(--height-h-5,20px)]">

// ✅ Tailwind標準クラスに変換
<div className="w-4 h-5">
```

#### ボーダー半径(border-radius)

```typescript
// ❌ Figma MCPが生成したコード
<div className="rounded-[var(--border-radius-rounded-md,8px)]">

// ✅ Tailwind標準クラスに変換
<div className="rounded-md">
```

#### タイポグラフィ(typography)

```typescript
// ❌ Figma MCPが生成したコード(インラインスタイル)
<h1 style={{
  fontFamily: 'var(--h4-font-family)',
  fontSize: 'var(--h4-font-size)',
  fontWeight: 'var(--h4-font-weight)',
  lineHeight: 'var(--h4-line-height)',
}}>

// ✅ Tailwind標準クラスに変換
<h1 className="text-h4">

// または Tailwind標準で代用可能な場合
<p className="text-sm">  // body2と同等 (14px/20px)
<p className="text-base">  // body1と同等 (16px/24px)
```

**実装済みのカスタムクラス:**(tailwind.config.tsで定義済み)

- `text-h4`: 24px/32px/bold
- `text-h5`: 20px/28px/bold
- `text-title`: 18px/28px/bold
- `text-body1`: 16px/24px/normal
- `text-body2`: 14px/20px/normal
- `text-body3`: 12px/16px/normal

**注意**: 新規デザイン変換時は必ずFigma MCPのHEX/px値を確認し、既存クラスと比較すること。名前の類似性だけで判断しない。

### ステップ3: カラーの扱い

カラーは**Figma MCPから届くHEX値を確認**して、適切に変換します。

```typescript
// ❌ Figma独自変数の直接使用は禁止
<div className="bg-[var(--base-primary)]">
<div className="text-[var(--base-foreground)]">

// ✅ 正しい実装
// 1. まずFigmaのHEX値と既存のshadcn/ui変数を比較
//    --base-primary: #00a0e9 = --primary: #00a0e9 → 同じ色!
<div className="bg-primary text-primary-foreground">

// 2. shadcn/uiにない独自色の場合はtailwind.config.tsに追加
//    --base-dark-primary: #006cab → shadcn/uiにない
//    → tailwind.config.tsに 'dark-primary': '#006cab' を追加
<div className="text-dark-primary">
```

**重要な原則:**
- **名前の類似性だけで判断しない** - 必ずHEX値を確認する
- Figma MCPからはHEX形式で届くので、既存のshadcn/ui変数(HSL形式)と比較
- 同じ色なら既存の変数を使用(例: `bg-primary`)
- 異なる色ならtailwind.config.tsにカスタム定義を追加

### ステップ4: 標準にない値の対応

マッピングにない値を発見した場合:

1. **tailwind.config.tsに追加**
   ```typescript
   theme: {
     extend: {
       spacing: {
         '13': '52px',  // 新しいカスタム値
       }
     }
   }
   ```

2. **figma-tailwind-map.tsに追加**
   ```typescript
   export const spacingMap: Record<string, number | string> = {
     // ... 既存のマッピング
     'spacing/13': 13,  // 新しいマッピング
   }
   ```

3. **実装で使用**
   ```typescript
   <div className="px-13">
   ```

## 禁止事項

### ❌ Figma変数の直接使用

```typescript
// 禁止
<div className="px-[var(--spacing-4)]">
<div className="gap-[var(--spacing-2,8px)]">
<div style={{ width: 'var(--width-w-4)' }}>
```

### ❌ カスタムユーティリティクラス

```css
/* globals.cssに以下を追加するのは禁止 */
.w-spacing-2 {
  width: var(--spacing-2);
}

.header-base {
  height: var(--height-h-16);
}
```

### ❌ インラインスタイルの乱用

```typescript
// 特別な理由がない限り禁止
<div style={{
  fontSize: 'var(--h4-font-size)',
  padding: 'var(--spacing-4)'
}}>
```

## 実装例

### Before(Figma MCPが生成)

```tsx
export default function Main() {
  return (
    <div className="bg-[var(--base/background-gray,#f6f8f9)] border-[var(--base/border,#edeef1)] border-b-0 border-l-[var(--border-width/border,1px)]">
      <div className="bg-[var(--base/background,#ffffff)] h-[64px] px-[var(--spacing/4,16px)] py-0">
        <div className="gap-[var(--spacing/2,8px)]">
          <div className="rounded-[var(--border-radius/rounded-md,8px)] size-[28px]">
            <Icon className="size-[16px]" />
          </div>
          <div className="gap-[var(--spacing/3,12px)]">
            <div style={{
              fontFamily: 'var(--h5-font-family)',
              fontSize: 'var(--h5-font-size)',
              fontWeight: 'var(--h5-font-weight)',
              lineHeight: 'var(--h5-line-height)',
            }}>
              サポート
            </div>
          </div>
        </div>
      </div>
    </div>
  )
}
```

### After(Tailwind標準クラスに変換)

```tsx
export default function Main() {
  return (
    <div className="bg-muted border border-l border-b-0">
      <div className="bg-background h-16 px-4 py-0">
        <div className="gap-2">
          <div className="rounded-md size-7">
            <Icon className="size-4" />
          </div>
          <div className="gap-3">
            <div className="text-h5">
              サポート
            </div>
          </div>
        </div>
      </div>
    </div>
  )
}
```

## チェックリスト

変換時に以下を確認してください:

- [ ] `var(--spacing-*)`を`px-*`, `py-*`, `gap-*`等に変換
- [ ] `var(--width-*)`を`w-*`に変換
- [ ] `var(--height-*)`を`h-*`に変換
- [ ] `var(--border-radius-*)`を`rounded-*`に変換
- [ ] インラインスタイルのフォント指定を`text-*`クラスに変換
- [ ] カラーはCSS変数のまま保持
- [ ] 標準にない値は`tailwind.config.ts`に追加
- [ ] カスタムユーティリティクラスを作成していない

## 参照ドキュメント

- **変換マッピング**: `frontend/lib/figma-tailwind-map.ts`
- **Tailwind設定**: `frontend/tailwind.config.ts`
- **開発ガイド**: `documents/development/coding-rules/frontend-rules.md` セクション12

## 注意事項

- このスキルは**Figma MCPのコード生成後に自動的に適用**されるべきです
- 変換後のコードは必ずLintとBuildチェックを行ってください
- 疑問がある場合は、必ず`figma-tailwind-map.ts`を参照してください
- カラー定義は例外として、常にCSS変数を使用してください

Related Skills

tailwind-design-system

242
from aiskillstore/marketplace

Build scalable design systems with Tailwind CSS, design tokens, component libraries, and responsive patterns. Use when creating component libraries, implementing design systems, or standardizing UI patterns.

figma-automation

242
from aiskillstore/marketplace

Automate Figma tasks via Rube MCP (Composio): files, components, design tokens, comments, exports. Always search tools first for current schemas.

tailwind-v4-shadcn

242
from aiskillstore/marketplace

Set up Tailwind v4 with shadcn/ui using @theme inline pattern and CSS variable architecture. Four-step pattern: CSS variables, Tailwind mapping, base styles, automatic dark mode. Prevents 8 documented errors. Use when initializing React projects with Tailwind v4, or fixing colors not working, tw-animate-css errors, @theme inline dark mode conflicts, @apply breaking, v3 migration issues.

expo-tailwind-setup

242
from aiskillstore/marketplace

Set up Tailwind CSS v4 in Expo with react-native-css and NativeWind v5 for universal styling

tailwind-css-v4-mastery

242
from aiskillstore/marketplace

Expert guidance for leveraging Tailwind CSS V4's new Oxide engine, CSS-first configuration, and modern styling paradigms. This skill transforms Claude into a Tailwind V4 architecture specialist, capable of designing component systems, optimizing performance, and executing complex styling challenges with precision.

tailwind-css

242
from aiskillstore/marketplace

Use when styling UI components or layouts with Tailwind CSS - mobile-first design, responsive utilities, custom themes, or component styling. NOT when plain CSS, CSS-in-JS (styled-components), or non-Tailwind frameworks are involved. Triggers: "style component", "responsive design", "mobile-first", "dark theme", "tailwind classes", "dashboard grid".

tailwind-patterns

242
from aiskillstore/marketplace

Quick reference for Tailwind CSS utility patterns, responsive design, and configuration. Triggers on: tailwind, utility classes, responsive design, tailwind config, dark mode css, tw classes.

azure-quotas

242
from aiskillstore/marketplace

Check/manage Azure quotas and usage across providers. For deployment planning, capacity validation, region selection. WHEN: "check quotas", "service limits", "current usage", "request quota increase", "quota exceeded", "validate capacity", "regional availability", "provisioning limits", "vCPU limit", "how many vCPUs available in my subscription".

DevOps & Infrastructure

raindrop-io

242
from aiskillstore/marketplace

Manage Raindrop.io bookmarks with AI assistance. Save and organize bookmarks, search your collection, manage reading lists, and organize research materials. Use when working with bookmarks, web research, reading lists, or when user mentions Raindrop.io.

Data & Research

zlibrary-to-notebooklm

242
from aiskillstore/marketplace

自动从 Z-Library 下载书籍并上传到 Google NotebookLM。支持 PDF/EPUB 格式,自动转换,一键创建知识库。

discover-skills

242
from aiskillstore/marketplace

当你发现当前可用的技能都不够合适(或用户明确要求你寻找技能)时使用。本技能会基于任务目标和约束,给出一份精简的候选技能清单,帮助你选出最适配当前任务的技能。

web-performance-seo

242
from aiskillstore/marketplace

Fix PageSpeed Insights/Lighthouse accessibility "!" errors caused by contrast audit failures (CSS filters, OKLCH/OKLAB, low opacity, gradient text, image backgrounds). Use for accessibility-driven SEO/performance debugging and remediation.