web-ui-shadcn-ui
shadcn/uiコンポーネントライブラリのパターンやCLIの使い方、テーマ設定、カスタマイズに関する情報を活用し、洗練されたWebアプリケーションのUIを効率的に構築・改善するSkill。
📜 元の英語説明(参考)
shadcn/ui component library patterns, CLI usage, theming, customization
🇯🇵 日本人クリエイター向け解説
shadcn/uiコンポーネントライブラリのパターンやCLIの使い方、テーマ設定、カスタマイズに関する情報を活用し、洗練されたWebアプリケーションのUIを効率的に構築・改善するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o web-ui-shadcn-ui.zip https://jpskill.com/download/10321.zip && unzip -o web-ui-shadcn-ui.zip && rm web-ui-shadcn-ui.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10321.zip -OutFile "$d\web-ui-shadcn-ui.zip"; Expand-Archive "$d\web-ui-shadcn-ui.zip" -DestinationPath $d -Force; ri "$d\web-ui-shadcn-ui.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
web-ui-shadcn-ui.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
web-ui-shadcn-uiフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] web-ui-shadcn-ui
shadcn/ui コンポーネントパターン
クイックガイド: shadcn/ui は、Radix primitives と Tailwind を基盤とする、コピーして所有するコンポーネントシステムです。
npx shadcn@latest addを使用して、コンポーネントをcomponents/ui/にインストールします。OKLCH 形式の CSS カスタムプロパティでテーマを設定します。複合コンポーネントパターンで構成します。クラスのマージにはcn()ユーティリティを使用します。新しいFieldコンポーネントは、フォームライブラリに依存しないフィールドレイアウトのために、従来のForm/FormFieldパターンを置き換えます。
<critical_requirements>
重要: この Skill を使用する前に
すべてのコードは、CLAUDE.md のプロジェクト規約 (kebab-case、名前付きエクスポート、インポート順序、
import type、名前付き定数) に従う必要があります
(コンポーネントを追加するには、CLI (npx shadcn@latest add [component]) を必ず使用してください - 手動コピーは不可)
(コンポーネントのカスタマイズは、CSS 変数と cn() ユーティリティを通じて行ってください - スタイルを直接上書きすることは不可)
(コンポーネントは必ず components/ui/ ディレクトリに保持してください - これは shadcn の規約です)
(新しい背景色ごとに、必ず前景の色を定義してください - --brand には --brand-foreground が必要です)
</critical_requirements>
自動検出: shadcn/ui, shadcn, @shadcn, components.json, npx shadcn, cn() ユーティリティ, ui components, Radix-based components, data-slot, Field component, cva variants
使用する場合:
- アクセシブルでカスタマイズ可能な UI コンポーネントを使用して React アプリケーションを構築する場合
- 完全なソース管理を備えた、コピーして所有するコンポーネントライブラリをセットアップする場合
- OKLCH カラーとダークモードで CSS 変数によるテーマ設定を実装する場合
- 新しい Field コンポーネント (フォームライブラリに依存しない) を使用してフォームを作成する場合
- 複合コンポーネント (Card, Dialog, Sheet, Tabs, Command) を使用する場合
使用しない場合:
- 特定の独自の設計システムが必要なプロジェクト
- コンポーネントのソースを制御できないアプリケーション
- Tailwind CSS を使用していないプロジェクト
カバーする主要なパターン:
- CLI インストール、検査フラグ、およびコンポーネント管理
- OKLCH 形式と Tailwind v4 を使用した CSS 変数によるテーマ設定
- 競合のないクラスのマージのための cn() ユーティリティ
- 複合コンポーネントの構成と拡張
- フォームライブラリに依存しないフィールドレイアウトのための Field コンポーネント
- cva (class-variance-authority) を使用したバリアントシステム
<philosophy>
哲学
shadcn/ui は 従来のコンポーネントライブラリではありません - これはコンポーネントライブラリを構築する方法です。コンポーネントは CLI を介してコードベースにコピーされ、完全な所有権が付与されます。コア機能 (アクセシビリティ、キーボードナビゲーション) は Radix primitives から提供されます。スタイリングレイヤーはカスタマイズ可能です。
5 つのコア原則:
- オープンコード - コンポーネントのソースは表示および変更可能
- 構成 - 一貫性のある、構成可能な複合コンポーネントインターフェース
- 配布 - CLI とフラットファイルスキーマによりコンポーネントの配布が可能
- 美しいデフォルト - そのまま使えるように慎重にキュレーションされたスタイリング
- AI 対応 - オープンソースアーキテクチャにより、ツールがコンポーネントを読み取り、改善することが可能
shadcn/ui が処理するものと、他の Skill が処理するもの:
- shadcn/ui: コンポーネント構造、CSS 変数、cn() ユーティリティ、構成パターン、Field レイアウト
- スタイリングのアプローチ: Tailwind 構成、ユーティリティクラスの規約、カスタム CSS
- フォームライブラリ: useForm フック、検証スキーマ、送信ロジック、状態管理
</philosophy>
<patterns>
コアパターン
パターン 1: CLI インストールと管理
コンポーネントを追加するには、必ず CLI を使用してください。依存関係を解決し、Radix パッケージをインストールし、適切なファイル構造を作成します。
# 初期化 (components.json を作成)
npx shadcn@latest init
# コンポーネントの追加
npx shadcn@latest add button card dialog
# 検査フラグ (CLI v4)
npx shadcn@latest add button --dry-run # 変更のプレビュー
npx shadcn@latest add button --diff # 更新の確認
npx shadcn@latest add button --view # コンポーネントのペイロードの表示
# Monorepo のサポート
npx shadcn@latest add button --path=packages/ui/src/components
# プロジェクト情報 (AI エージェントに役立ちます)
npx shadcn@latest info
# CLI からコンポーネントのドキュメントを表示 (v4)
npx shadcn@latest docs combobox
コンポーネントは components/ui/ に配置されます。cn() ユーティリティは lib/utils.ts に配置されます。どちらも自動的に作成されます。
良い理由: CLI は依存関係の解決を処理し、変更前に検査を提供し、コンポーネントは所有されたソースコードになります
パターン 2: CSS 変数によるテーマ設定 (OKLCH)
shadcn/ui は、OKLCH カラー形式 (Tailwind v4) の CSS カスタムプロパティを使用します。すべての色は、背景/前景の命名規則に従います。
/* 命名規則 - これを理解し、値を暗記しないでください */
:root {
--primary: oklch(0.205 0 0); /* 背景色 */
--primary-foreground: oklch(0.985 0 0); /* その背景の上のテキスト */
}
.dark {
--primary: oklch(0.985 0 0); /* ダークモード用に反転 */
--primary-foreground: oklch(0.205 0 0);
}
古い shadcn バージョンからの Tailwind v4 の主な変更点:
- OKLCH は、より優れた知覚的均一性のために HSL を置き換えます
@theme inlineディレクティブは、CSS 変数を Tailwind ユーティリティにマッピングします@custom-variant darkは、ダークモードセレクターを定義します--chart-*および--sidebar-*変数ファミリーは、特殊なコンポーネント用です- 計算された半径:
--radius-sm/md/lg/xlは、ベースの--radiusから派生します
カスタムカラーを追加するには、CSS 変数と @theme inline マッピングの両方が必要です。
:root {
--brand: oklch(0.627 0.265 303.9);
--brand-foreground: oklch(1 0 0);
}
@theme inline {
--color-brand: var(--brand);
--color-brand-foreground: var(--brand-foreground);
}
次に、bg-brand text-brand-foreground hover:bg-brand/90 として使用します
完全な変数リファレンスとカスタムカラーの例については、examples/theming.md を参照してください。
パターン 3: cn() ユーティリティ
clsx (条件付きクラス) と tailwind-merge (競合解決) を組み合わせます。コンシューマーの className は、オーバーライドが機能するように常に最後に記述します。
// lib/utils.ts - shadcn init によって自動生成
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: Class 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
shadcn/ui Component Patterns
Quick Guide: shadcn/ui is a copy-and-own component system built on Radix primitives and Tailwind. Use
npx shadcn@latest addto install components intocomponents/ui/. Theme via CSS custom properties in OKLCH format. Compose with compound component patterns. Use thecn()utility for class merging. NewFieldcomponent replaces the oldForm/FormFieldpattern for form-library-agnostic field layout.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST use the CLI to add components - npx shadcn@latest add [component] - not manual copy)
(You MUST customize components through CSS variables and the cn() utility - not direct style overrides)
(You MUST keep components in the components/ui/ directory - this is the shadcn convention)
(You MUST define foreground colors for every new background color - --brand needs --brand-foreground)
</critical_requirements>
Auto-detection: shadcn/ui, shadcn, @shadcn, components.json, npx shadcn, cn() utility, ui components, Radix-based components, data-slot, Field component, cva variants
When to use:
- Building React applications with accessible, customizable UI components
- Setting up a copy-and-own component library with full source control
- Implementing CSS variable theming with OKLCH colors and dark mode
- Creating forms with the new Field component (form-library-agnostic)
- Using compound components (Card, Dialog, Sheet, Tabs, Command)
When NOT to use:
- Projects requiring a specific opinionated design system
- Applications where you cannot control the component source
- Projects not using Tailwind CSS
Key patterns covered:
- CLI installation, inspection flags, and component management
- CSS variable theming with OKLCH format and Tailwind v4
- cn() utility for conflict-free class merging
- Compound component composition and extension
- Field component for form-library-agnostic field layout
- Variant system with cva (class-variance-authority)
<philosophy>
Philosophy
shadcn/ui is not a traditional component library - it is how you build your component library. Components are copied into your codebase via CLI, giving you full ownership. Core functionality (accessibility, keyboard nav) comes from Radix primitives; the styling layer is yours to customize.
Five Core Principles:
- Open Code - Component source is visible and modifiable
- Composition - Consistent, composable compound component interfaces
- Distribution - CLI and flat-file schema enable component distribution
- Beautiful Defaults - Carefully curated styling that works out of the box
- AI-Ready - Open source architecture allows tools to read and improve components
What shadcn/ui handles vs what other skills handle:
- shadcn/ui: component structure, CSS variables, cn() utility, composition patterns, Field layout
- Your styling approach: Tailwind configuration, utility class conventions, custom CSS
- Your form library: useForm hook, validation schemas, submission logic, state management
</philosophy>
<patterns>
Core Patterns
Pattern 1: CLI Installation and Management
Always use the CLI to add components. It resolves dependencies, installs Radix packages, and creates proper file structure.
# Initialize (creates components.json)
npx shadcn@latest init
# Add components
npx shadcn@latest add button card dialog
# Inspection flags (CLI v4)
npx shadcn@latest add button --dry-run # Preview changes
npx shadcn@latest add button --diff # Check for updates
npx shadcn@latest add button --view # Display component payload
# Monorepo support
npx shadcn@latest add button --path=packages/ui/src/components
# Project info (useful for AI agents)
npx shadcn@latest info
# View component docs from CLI (v4)
npx shadcn@latest docs combobox
Components go in components/ui/. The cn() utility goes in lib/utils.ts. Both are created automatically.
Why good: CLI handles dependency resolution, provides inspection before changes, components become owned source code
Pattern 2: CSS Variable Theming (OKLCH)
shadcn/ui uses CSS custom properties with OKLCH color format (Tailwind v4). Every color follows a background/foreground naming convention.
/* The naming convention - understand this, don't memorize values */
:root {
--primary: oklch(0.205 0 0); /* Background color */
--primary-foreground: oklch(0.985 0 0); /* Text ON that background */
}
.dark {
--primary: oklch(0.985 0 0); /* Inverted for dark mode */
--primary-foreground: oklch(0.205 0 0);
}
Key Tailwind v4 changes from older shadcn versions:
- OKLCH replaces HSL for better perceptual uniformity
@theme inlinedirective maps CSS variables to Tailwind utilities@custom-variant darkdefines dark mode selector--chart-*and--sidebar-*variable families for specialized components- Computed radius:
--radius-sm/md/lg/xlderived from base--radius
Adding custom colors requires both the CSS variable AND the @theme inline mapping:
:root {
--brand: oklch(0.627 0.265 303.9);
--brand-foreground: oklch(1 0 0);
}
@theme inline {
--color-brand: var(--brand);
--color-brand-foreground: var(--brand-foreground);
}
Then use as: bg-brand text-brand-foreground hover:bg-brand/90
See examples/theming.md for complete variable reference and custom color examples.
Pattern 3: The cn() Utility
Combines clsx (conditional classes) with tailwind-merge (conflict resolution). Consumer className always comes last so overrides work.
// lib/utils.ts - auto-generated by shadcn init
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
// Usage in components - className last for consumer overrides
function Card({ className, ...props }: CardProps) {
return (
<div
className={cn("rounded-lg border bg-card shadow-sm", className)}
{...props}
/>
);
}
Critical behavior: cn("px-4", "px-8") produces "px-8" (last wins), not "px-4 px-8". This is why consumer className overrides work correctly.
See examples/core.md for more cn() examples.
Pattern 4: Component Extension with Variants
Use cva (class-variance-authority) for variant-based component styling. This is how shadcn/ui itself structures Button, Badge, and Alert.
import { cva, type VariantProps } from "class-variance-authority";
const buttonVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline: "border border-input bg-background hover:bg-accent",
ghost: "hover:bg-accent hover:text-accent-foreground",
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 px-3",
lg: "h-11 px-8",
icon: "h-10 w-10",
},
},
defaultVariants: { variant: "default", size: "default" },
},
);
To add a new variant, edit the component source directly - you own it. To use variants: <Button variant="destructive" size="sm">.
See examples/composition.md for extended button with loading state and responsive dialog/drawer patterns.
Pattern 5: Field Component (Form Layout)
The Field component is the modern form-library-agnostic way to compose form fields. It provides labels, descriptions, error messages, and accessibility - without coupling to any specific form library.
import {
Field,
FieldLabel,
FieldDescription,
FieldError,
} from "@/components/ui/field";
import { Input } from "@/components/ui/input";
// Field is a layout primitive - bring your own form library
<Field data-invalid={hasError}>
<FieldLabel htmlFor="email">Email</FieldLabel>
<Input id="email" aria-invalid={hasError} {...fieldProps} />
<FieldDescription>We will never share your email.</FieldDescription>
{hasError && <FieldError errors={errors} />}
</Field>;
Replaces the old Form/FormField/FormItem/FormControl/FormMessage pattern which was tightly coupled to React Hook Form. The Field component works with any form library or server actions.
Related components: FieldGroup for grouping related fields, FieldSet and FieldLegend for semantic grouping.
See examples/forms.md for complete form integration examples.
Pattern 6: Compound Component Composition
shadcn/ui uses compound components (Card, Dialog, Sheet, Tabs, Command) with consistent sub-component patterns. Extend by wrapping, not replacing.
// CORRECT: Extend by wrapping compound components
function ProductCard({ title, price, ...props }: ProductCardProps) {
return (
<Card {...props}>
<CardHeader>
<CardTitle>{title}</CardTitle>
<CardDescription>${price}</CardDescription>
</CardHeader>
</Card>
);
}
// WRONG: Breaking compound structure with plain divs
<div className="card">
<div className="card-header">
<h2>{title}</h2>
</div>
</div>;
asChild prop - Use when composing interactive elements to avoid nesting (e.g., Button wrapping a Link):
<Button asChild>
<Link href="/dashboard">Dashboard</Link>
</Button>
See examples/dialogs.md for AlertDialog, Sheet, and toast patterns. See examples/data-table.md for table with row actions. See examples/command-palette.md for command menu.
Pattern 7: New Components (October 2025+)
Recent additions that solve common patterns:
| Component | Purpose | Install |
|---|---|---|
| Field | Form-library-agnostic field layout | npx shadcn@latest add field |
| Spinner | Loading indicator (replaces custom ones) | npx shadcn@latest add spinner |
| Kbd | Keyboard shortcut display | npx shadcn@latest add kbd |
| Button Group | Grouped button container | npx shadcn@latest add button-group |
| Input Group | Input with addons (icons, buttons) | npx shadcn@latest add input-group |
| Item | Flex container for lists/cards | npx shadcn@latest add item |
| Empty | Empty state display | npx shadcn@latest add empty |
These components work across Radix and Base UI primitives.
Pattern 8: Recent Platform Changes
Unified Radix UI package (Feb 2026): Individual @radix-ui/react-* packages are now a single radix-ui package. Migrate with npx shadcn@latest migrate radix.
// Old (pre-Feb 2026)
import * as DialogPrimitive from "@radix-ui/react-dialog";
// New (unified package)
import { Dialog as DialogPrimitive } from "radix-ui";
CLI v4 (March 2026):
npx shadcn@latest docs [component]- View component docs from CLI (useful for AI agents)npx shadcn@latest init --template- Full project scaffolding for Next.js, Vite, Astro, React Router, TanStack Start, Laravel--presetflag packs entire design system config (colors, fonts, radius, icons) into a shareable codeshadcn/skills- AI agent context for component patterns and registry workflowsregistry:base- Distribute entire design systems as single payloads
RTL support (Jan 2026): First-class right-to-left layout support. The CLI transforms physical CSS classes to logical equivalents at install time.
</patterns>
Detailed Resources:
- examples/core.md - Setup, cn() utility, skeleton loading
- examples/composition.md - Extended button, responsive dialog/drawer
- examples/forms.md - Field component, form integration patterns
- examples/dialogs.md - AlertDialog, Sheet, toast patterns, dark mode provider
- examples/data-table.md - Sortable table with row actions
- examples/command-palette.md - Command menu with keyboard navigation
- examples/theming.md - Complete CSS variables, custom colors, theme toggle
- reference.md - Decision frameworks, anti-patterns, checklists
<red_flags>
RED FLAGS
High Priority Issues:
- Not using CLI for installation - Manual copy misses dependencies and proper file structure
- Breaking OKLCH format - Wrapping values in
hsl()when they are already OKLCH - Not using cn() - Direct className concatenation breaks Tailwind class merging
- Missing components.json - CLI commands will fail without configuration
- Hardcoding colors - Use CSS variables for theme consistency
Medium Priority Issues:
- Overriding styles with !important - Use cn() and proper class ordering instead
- Not exposing className prop - Custom components should accept className for override
- Ignoring accessibility attributes - Radix provides them; custom extensions can break them
- Not updating both :root and .dark - New colors need both light and dark mode
Gotchas & Edge Cases:
- Foreground convention -
--primary-foregroundis text color ON--primarybackground, not primary-colored text - React 19 - No
forwardRefneeded;refis now a regular prop. Components usedata-slotattributes asChildrequired for Link composition - Prevents nested interactive elements (button inside anchor)- Select controlled usage - Requires both
onValueChangeanddefaultValue(orvalue) - Chart config (Tailwind v4) - Use
var(--chart-1)directly, nohsl()wrapper needed suppressHydrationWarning- Required on<html>when using theme provider to prevent hydration mismatch- Old Form components -
Form/FormField/FormItem/FormControl/FormMessageare legacy; preferFieldcomponent for new code - Base UI option - Since Feb 2026, you can choose between Radix and Base UI as the primitive library (
--base radixor--base base) - Unified Radix package - Since Feb 2026, import from
radix-ui(not individual@radix-ui/react-*packages). Migrate withnpx shadcn@latest migrate radix
</red_flags>
<critical_reminders>
CRITICAL REMINDERS
All code must follow project conventions in CLAUDE.md
(You MUST use the CLI to add components - npx shadcn@latest add [component] - not manual copy)
(You MUST customize components through CSS variables and the cn() utility - not direct style overrides)
(You MUST keep components in the components/ui/ directory - this is the shadcn convention)
(You MUST define foreground colors for every new background color - --brand needs --brand-foreground)
Failure to follow these rules will break component updates, cause styling conflicts, and violate shadcn/ui conventions.
</critical_reminders>