jpskill.com
💬 コミュニケーション コミュニティ

tailwind-css-v4-mastery

Tailwind CSS V4の新しいエンジンやCSS優先の設定を活用し、コンポーネント設計やパフォーマンス最適化、高度なスタイリング課題を正確に実行できる、Tailwind V4アーキテクチャのエキスパートとしてClaudeを支援するSkill。

📜 元の英語説明(参考)

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 V4の新しいエンジンやCSS優先の設定を活用し、コンポーネント設計やパフォーマンス最適化、高度なスタイリング課題を正確に実行できる、Tailwind V4アーキテクチャのエキスパートとしてClaudeを支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o tailwind-css-v4-mastery.zip https://jpskill.com/download/17723.zip && unzip -o tailwind-css-v4-mastery.zip && rm tailwind-css-v4-mastery.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17723.zip -OutFile "$d\tailwind-css-v4-mastery.zip"; Expand-Archive "$d\tailwind-css-v4-mastery.zip" -DestinationPath $d -Force; ri "$d\tailwind-css-v4-mastery.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して tailwind-css-v4-mastery.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → tailwind-css-v4-mastery フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
3

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Tailwind CSS V4 マスタリースキル

哲学: CSS-First Thinking

Tailwind V4 は、JavaScript 中心の実用性フレームワークから、CSS ネイティブな宣言的スタイリングへの哲学的な転換を表しています。このスキルは、そのメンタルモデルをインストールします。

  • 設定は CSStailwind.config.js@theme {} に置き換えられます
  • スピードはアーキテクチャ — Oxide エンジン (Rust) が JavaScript パーサーに取って代わります
  • モダンスタンダードファースト@propertycolor-mix()、CSS ネスティングを活用します
  • パフォーマンスを第一級市民として — v3 より 10〜100 倍高速

V4 の正しいメンタルモデル: 「CSS が真実の源です。JavaScript の設定は時代遅れです。」


コアとなる概念的ランドスケープ

1. Oxide エンジンの革命

何が変わったか:

v3: JavaScript → JavaScript Parser → CSS Output
v4: CSS @theme → Rust/Oxide Engine → Optimized CSS Output

なぜ重要なのか:

  • パフォーマンス: ビルド時間が 10〜100 倍高速、HMR が 15〜30 倍高速
  • シンプルさ: 2 つの言語 (JS + CSS) ではなく、1 つの言語 (CSS)
  • 将来性: ネイティブブラウザの機能に準拠

メンタルモデル: Oxide エンジンをプリプロセッサではなく、コンパイラとして考えてください。CSS 宣言をコンパイルして最適化された出力にします。

2. CSS-First 設定パラダイム

コアとなる変化:

側面 v3 v4
設定形式 JavaScript Object CSS @theme {} ブロック
場所 tailwind.config.js styles.css
実行 ビルド時の Node.js Oxide エンジン
デバッグ コンソールログ、ファイル検査 CSS DevTools
スコープ グローバルインポート CSS カスケード対応

なぜこれが重要なのか: CSS-first 設定は、より保守しやすく、デバッグしやすく、ブラウザの実際の動作と一致しています。抽象化のレイヤーと戦う必要はもうありません。

3. ブラウザ要件と最新の CSS 機能

Tailwind V4 は、最新のブラウザ機能を必要とします。

  • Safari 16.4+ (OKLch カラースペース、@property)
  • Chrome 111+ (color-mix())
  • Firefox 128+ (CSS ネスティング)

これは意図的なものです。V4 は最新の CSS を前提とし、それに基づいて最適化します。レガシーサポートには v3.4.x が必要です。


手順ワークフロー

ワークフロー 1: V3 から V4 への移行

トリガー: ユーザーが既存の Tailwind プロジェクトを v3 から v4 にアップグレードしたい

手順:

  1. 監査フェーズ

    • すべての tailwind.config.js のオーバーライドをリストアップします
    • カスタムユーティリティとコンポーネントを特定します
    • 非推奨のユーティリティの使用法 (opacity、flex-shrink など) をスキャンします
    • ブラウザのサポート要件を確認します
  2. インストールフェーズ

    npm install -D tailwindcss@latest
    npm install -D @tailwindcss/vite  # (または @tailwindcss/postcss または @tailwindcss/cli)
  3. 設定の移行

    • theme: {}@theme { --var: value; } に変換します
    • extend: {}@theme に追加の --var を追加します
    • @tailwind base/components/utilities@import "tailwindcss" に置き換えます
  4. ユーティリティのリファクタリング

    • .shadow.shadow-sm
    • .rounded.rounded-sm
    • .outline-none.outline-hidden
    • .bg-opacity-*.bg-black/* (スラッシュ構文)
  5. 検証

    • レスポンシブブレークポイントをテストします
    • ダークモードを確認します
    • カスタムコンポーネントを確認します
    • パフォーマンスのベースライン

決定木:

これは新しいプロジェクトですか?
  ├─ YES → @theme 設定で V4 を直接使用します
  └─ NO → 上記の移行ワークフローを実行します
     ├─ v3 はカスタム設定を広範囲に使用していますか?
     │  ├─ YES → 移行時間を割り当て、段階的に進めます
     │  └─ NO → クイック移行、30 分
     └─ レガシーブラウザを使用していますか?
        ├─ YES → v3.4 を使用し続けます
        └─ NO → v4 に進みます

ワークフロー 2: コンポーネントシステム設計

トリガー: ユーザーが Tailwind V4 で再利用可能なコンポーネントライブラリを構築したい

手順:

  1. コンポーネントスコープの定義

    • コンポーネントプリミティブ (Button、Card、Input など) をリストアップします
    • 共有スタイリングパターンを特定します
    • テーマのカスタマイズを計画します
  2. ベーステーマの作成

    @import "tailwindcss";
    
    @theme {
      /* Color system */
      --color-primary-*: oklch(...);
      --color-neutral-*: oklch(...);
    
      /* Spacing scale */
      --spacing-xs: 0.25rem;
      --spacing-sm: 0.5rem;
      --spacing-md: 1rem;
    
      /* Typography */
      --font-display: "Custom", sans-serif;
      --font-body: "System", sans-serif;
    }
  3. コンポーネントクラスの構築

    @layer components {
      .btn-primary {
        @apply px-4 py-2 rounded-sm bg-primary text-white
               font-semibold transition-all hover:opacity-90;
      }
    
      .card {
        @apply p-6 rounded-lg bg-white shadow-md border border-gray-200;
      }
    }
  4. 修飾子の規約の確立

    • サイズ修飾子: .btn-sm.btn-lg
    • 状態修飾子: .btn-disabled.btn-loading
    • バリアント修飾子: .btn-primary.btn-secondary
  5. ドキュメント化とエクスポート

    • コンポーネントリファレンスを作成します
    • 使用例を提供します
    • テーマ変数をドキュメント化します

出力: 本番環境に対応したコンポーネントライブラリ CSS ファイル

ワークフロー 3: パフォーマンス最適化

トリガー: ユーザーが Tailwind V4 のパフォーマンスを最適化する必要がある

手順:

  1. ベースライン測定

    • 現在のビルド時間を測定します
    • CSS ファイルサイズを確認します
    • HMR 速度を監視します
  2. プラグインの選択

    • @tailwindcss/vite (最速のオプション) を使用します
    • PostCSS を使用している場合は Lightning CSS を有効にします
    • 不要な最適化を無効にします
  3. 設定の調整

    // vite.config.ts
    import tailwindcss from "@tailwindcss/vite";
    
    export default defineConfig({
      plugins: [react(), tailwindcss()]
    });
  4. CSS 変数の最適化

    • 計算された値の代わりに、ネイティブ CSS 変数を使用します
    • スコープされたテーマにカスケードを活用します
    • @theme ブロックの重複を最小限に抑えます
  5. 検証

    • ビルド時間の改善を確認します
    • ファイルサイズの削減を確認します
    • 視覚的な一貫性を確認します

期待される結果:

  • ビルド時間: 100〜500ms (v3 では 5〜10 秒)
  • ホットリロード: 50〜200ms (v3 では 3 秒)
  • CSS サイズ: -15〜20% 削減

重要な決定木

決定 1: プラグインの選択

` (原文がここで切り詰められています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Tailwind CSS V4 Mastery Skill

Philosophy: CSS-First Thinking

Tailwind V4 represents a philosophical shift from JavaScript-centric utility frameworks to CSS-native, declarative styling. This skill installs that mental model:

  • Configuration is CSS@theme {} replaces tailwind.config.js
  • Speed is Architectural — Oxide engine (Rust) replaces JavaScript parser
  • Modern Standards First — Leverages @property, color-mix(), CSS nesting
  • Performance as a First-Class Citizen — 10-100x faster than v3

The correct mental model for V4: "CSS is the source of truth. JavaScript configuration is outdated."


Core Conceptual Landscape

1. The Oxide Engine Revolution

What Changed:

v3: JavaScript → JavaScript Parser → CSS Output
v4: CSS @theme → Rust/Oxide Engine → Optimized CSS Output

Why It Matters:

  • Performance: 10-100x faster build times, 15-30x faster HMR
  • Simplicity: One language (CSS) instead of two (JS + CSS)
  • Future-Proofing: Aligned with native browser capabilities

Mental Model: Think of the Oxide engine as a compiler, not a preprocessor. It compiles CSS declarations into optimized output.

2. CSS-First Configuration Paradigm

The Core Shift:

Aspect v3 v4
Config Format JavaScript Object CSS @theme {} Block
Location tailwind.config.js styles.css
Execution Node.js at build time Oxide engine
Debugging Console logs, file inspection CSS DevTools
Scope Global import CSS cascade-aware

Why This Matters: CSS-first configuration is more maintainable, debuggable, and aligned with how browsers actually work. You're no longer fighting a layer of abstraction.

3. Browser Requirements & Modern CSS Features

Tailwind V4 requires modern browser capabilities:

  • Safari 16.4+ (OKLch color space, @property)
  • Chrome 111+ (color-mix())
  • Firefox 128+ (CSS nesting)

This is intentional. V4 assumes modern CSS and optimizes around it. Legacy support requires v3.4.x.


Procedural Workflows

Workflow 1: Migration from V3 to V4

Trigger: User wants to upgrade existing Tailwind project from v3 to v4

Steps:

  1. Audit Phase

    • List all tailwind.config.js overrides
    • Identify custom utilities and components
    • Scan for deprecated utility usage (opacity, flex-shrink, etc.)
    • Check browser support requirements
  2. Installation Phase

    npm install -D tailwindcss@latest
    npm install -D @tailwindcss/vite  # (or @tailwindcss/postcss or @tailwindcss/cli)
  3. Configuration Migration

    • Convert theme: {}@theme { --var: value; }
    • Convert extend: {} → Additional --var in @theme
    • Replace @tailwind base/components/utilities@import "tailwindcss"
  4. Utility Refactoring

    • .shadow.shadow-sm
    • .rounded.rounded-sm
    • .outline-none.outline-hidden
    • .bg-opacity-*.bg-black/* (slash syntax)
  5. Validation

    • Test responsive breakpoints
    • Verify dark mode
    • Check custom components
    • Performance baseline

Decision Tree:

Is this a new project?
  ├─ YES → Use V4 directly with @theme config
  └─ NO → Execute migration workflow above
     ├─ Does v3 use custom config extensively?
     │  ├─ YES → Allocate migration time, go step-by-step
     │  └─ NO → Quick migration, 30 mins
     └─ Are you on legacy browsers?
        ├─ YES → Stay on v3.4
        └─ NO → Proceed with v4

Workflow 2: Component System Design

Trigger: User wants to build reusable component library with Tailwind V4

Steps:

  1. Define Component Scope

    • List component primitives (Button, Card, Input, etc.)
    • Identify shared styling patterns
    • Plan for theme customization
  2. Create Base Theme

    @import "tailwindcss";
    
    @theme {
      /* Color system */
      --color-primary-*: oklch(...);
      --color-neutral-*: oklch(...);
    
      /* Spacing scale */
      --spacing-xs: 0.25rem;
      --spacing-sm: 0.5rem;
      --spacing-md: 1rem;
    
      /* Typography */
      --font-display: "Custom", sans-serif;
      --font-body: "System", sans-serif;
    }
  3. Build Component Classes

    @layer components {
      .btn-primary {
        @apply px-4 py-2 rounded-sm bg-primary text-white
               font-semibold transition-all hover:opacity-90;
      }
    
      .card {
        @apply p-6 rounded-lg bg-white shadow-md border border-gray-200;
      }
    }
  4. Establish Modifier Conventions

    • Size modifiers: .btn-sm, .btn-lg
    • State modifiers: .btn-disabled, .btn-loading
    • Variant modifiers: .btn-primary, .btn-secondary
  5. Document & Export

    • Create component reference
    • Provide usage examples
    • Document theme variables

Output: Production-ready component library CSS file

Workflow 3: Performance Optimization

Trigger: User needs to optimize Tailwind V4 performance

Steps:

  1. Baseline Measurement

    • Measure current build time
    • Check CSS file size
    • Monitor HMR speed
  2. Plugin Selection

    • Use @tailwindcss/vite (fastest option)
    • Enable Lightning CSS if using PostCSS
    • Disable unnecessary optimizations
  3. Configuration Tuning

    // vite.config.ts
    import tailwindcss from "@tailwindcss/vite";
    
    export default defineConfig({
      plugins: [react(), tailwindcss()]
    });
  4. CSS Variable Optimization

    • Use native CSS variables instead of computed values
    • Leverage cascade for scoped themes
    • Minimize @theme block duplication
  5. Validation

    • Verify build time improvement
    • Check file size reduction
    • Confirm visual consistency

Expected Outcomes:

  • Build time: 100-500ms (vs 5-10s in v3)
  • Hot reload: 50-200ms (vs 3s in v3)
  • CSS size: -15-20% reduction

Critical Decision Trees

Decision 1: Plugin Selection

What build tool do you use?
├─ Vite (React, Vue, Svelte)
│  └─ Use @tailwindcss/vite (fastest, recommended)
├─ Webpack (NextJS, CRA)
│  └─ Use @tailwindcss/postcss
├─ Standalone/No bundler
│  └─ Use @tailwindcss/cli
└─ PostCSS pipeline
   └─ Use @tailwindcss/postcss

Decision 2: Configuration Approach

How complex is your theme?
├─ Simple (5-10 color overrides)
│  └─ Use inline @theme block in styles.css
├─ Moderate (custom colors, spacing, fonts)
│  └─ Use single @theme block with organization
├─ Complex (multi-theme, extensive customization)
│  └─ Split into @layer base blocks with [data-theme] selectors
└─ Enterprise (multiple brands)
   └─ Use CSS variable strategy with fallbacks

Decision 3: Component Extraction

When should I use @layer components?
├─ Recurring utility combinations
│  └─ YES → Extract to .btn-primary, .card, etc.
├─ One-off layouts
│  └─ NO → Use utilities directly in HTML
├─ Design system compliance needed
│  └─ YES → Extract as component class
└─ User will customize per instance
   └─ NO → Leave as utility composition

Common Gotchas & Solutions

Gotcha 1: Expecting tailwind.config.js to Still Work

Problem: File is ignored in v4.
Solution: Use @theme {} in CSS instead.
Prevention: Delete tailwind.config.js early in migration.

Gotcha 2: Default Border Color Breaking Layouts

Problem: v3 used currentColor (inherits text), v4 uses #e5e7eb.
Solution: Use .border-current if you need inherited color.
Prevention: Test all border utilities during migration.

Gotcha 3: Ring Width Changed (3px → 1px)

Problem: Existing .ring classes now have thinner outlines.
Solution: Use .ring-3 for old 3px behavior, .ring-1 for new default.
Prevention: Find/replace .ring.ring-1 during migration.

Gotcha 4: CSS Variables Must Have -- Prefix

Problem: @theme { color-primary: value; } is ignored.
Solution: Use @theme { --color-primary: value; }.
Prevention: Always use -- in @theme blocks.

Gotcha 5: Opacity Utilities Removed

Problem: .bg-opacity-50 no longer exists.
Solution: Use CSS color modifiers: .bg-black/50.
Prevention: Search codebase for opacity utilities and replace during migration.


Reference Materials

All detailed references are stored in references/:

  • breaking-changes.md — Complete list of API removals and renames
  • configuration-guide.md — Comprehensive @theme setup patterns
  • utility-migration-table.md — v3 → v4 utility mappings
  • color-space-guide.md — OKLch, HSL, and color migration strategies
  • performance-tuning.md — Optimization techniques and measurements

When to Use This Skill

Use this skill when:

  • User asks about Tailwind V4 specifically (not v3)
  • Designing component systems or styling architectures
  • Migrating from Tailwind v3 to v4
  • Optimizing Tailwind performance
  • Troubleshooting CSS-first configuration issues
  • Building design systems with Tailwind V4
  • Creating custom theme configurations

Don't use this skill when:

  • User asks about Tailwind v3 or older (use general CSS knowledge)
  • Question is about HTML/JavaScript/Framework-specific issues (not Tailwind's domain)
  • User needs general CSS tutoring (use CSS fundamentals instead)
  • Building non-web projects

Execution Standards

When activated by user query:

  1. Clarify Intent — Ask what they're building and why (component? migration? optimization?)
  2. Choose Workflow — Route to appropriate procedural path
  3. Provide References — Link to relevant reference materials
  4. Show Code Examples — Concrete, copy-paste-ready examples
  5. Explain Trade-offs — Why certain decisions matter
  6. Test Assumptions — Verify understanding before deep work

Advanced Capabilities

This skill enables Claude to:

  • Design component systems that leverage Tailwind V4's architecture
  • Execute migrations from v3 to v4 with minimal risk
  • Optimize builds using Oxide engine capabilities
  • Debug CSS-first configuration issues systematically
  • Teach Tailwind V4 philosophy to teams
  • Architect design systems using CSS variables + Tailwind
  • Handle edge cases around browser support and feature detection

Resources & References


Skill Version: 1.0.0
Last Updated: 2025-01-01
Status: Production Ready

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。