shadcn/ui v2.5+ · Tailwind CSS v4
Admin Design System
shadcn/ui + Radix UI + Tailwind CSS v4 ベースの管理画面デザインシステム。 CSS変数による一貫したテーマと、コンポジションによる柔軟なUI構築。
Contents
Foundation
- Architecture
- CSS Variables
- Typography
- Spacing & Layout
Components (20+)
- Button, Badge, Card
- Dialog, Sheet, Command
- Table, Tabs, Pagination
- Input, Select, Checkbox
Data & Charts
- Charts (Recharts)
- TanStack Table
- Sidebar Layout
- Dashboard Blocks
Patterns
- File Upload
- Empty States
- Dark Mode
- Do's & Don'ts
Architecture
アクセシブルなプリミティブ
ユーティリティファースト
テーマトークン
一貫したアイコン
Responsive Design (Desktop First)
Desktop First 設計
管理画面は主にPCで操作されるため、デスクトップを基準に設計し、必要に応じてモバイル対応を追加
Breakpoints
xl:≥ 1280px大画面PCフルレイアウトlg:≥ 1024px標準PCデフォルト基準md:≥ 768pxタブレットサイドバー縮小sm:< 768pxモバイル最小限対応Container Width
max-w-7xl1280pxメインコンテンツmax-w-5xl1024pxフォーム・設定max-w-3xl768pxモーダル内コンテンツmax-w-md448pxダイアログSidebar Layout
// PC: 固定サイドバー <aside className=" w-64 lg:w-72 fixed lg:sticky lg:top-0 "> // タブレット: 縮小 md:w-16 // モバイル: ドロワー sm:hidden + Sheet
Grid Columns
// ダッシュボードカード grid-cols-1 md:grid-cols-2 lg:grid-cols-4 // データテーブル 常に横スクロール対応 min-w-[800px]
Navigation
// PC: フルナビ <nav className=" hidden lg:flex items-center gap-6 "> // モバイル: ハンバーガー lg:hidden + Sheet
- • PC(lg:)を基準にデザインする
- • サイドバーはPCでは常に表示
- • データテーブルは横スクロール許容
- • モーダル/ダイアログは max-w-md 〜 max-w-3xl
- • タブレットではサイドバーをアイコンのみに縮小
- • モバイルファーストで設計しない
- • テーブルを無理に縦積みにしない
- • PCでの操作性を犠牲にしない
- • 複雑なフォームをモバイル最適化しない
- • sm: ブレークポイントを多用しない
CSS Variables (Color Tokens)
Core Tokens
すべてのコンポーネントで使用
--backgroundBackground
0 0% 100%--foregroundForeground
240 10% 3.9%--cardCard
0 0% 100%--primaryPrimary
240 5.9% 10%--secondarySecondary
240 4.8% 95.9%--mutedMuted
240 4.8% 95.9%--accentAccent
240 4.8% 95.9%--borderBorder
240 5.9% 90%Semantic Tokens
状態表示にのみ使用
--destructiveDestructive(削除・エラー)
0 84% 60%--successSuccess(完了・公開中)
142 76% 36%--warningWarning(注意・準備中)
38 92% 50%globals.css での定義
:root {
--background: 0 0% 100%;
--foreground: 240 10% 3.9%;
--primary: 240 5.9% 10%;
--primary-foreground: 0 0% 98%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--border: 240 5.9% 90%;
--ring: 240 5.9% 10%;
--radius: 0.5rem;
}Official Components (shadcn/ui)
Button
npx shadcn@latest add button<Button variant="default">Default</Button> <Button variant="outline">Outline</Button> <Button variant="secondary">Secondary</Button> <Button variant="ghost">Ghost</Button> <Button variant="destructive">Destructive</Button> <Button variant="outline" size="icon"><Icon /></Button>
Badge
npx shadcn@latest add badgeCard
npx shadcn@latest add cardTotal Revenue
¥2,450,000
+12.5% from last month
Orders
1,234
+8.2% from last month
Active Users
5,678
-2.1% from last month
Dialog / AlertDialog
npx shadcn@latest add dialog alert-dialogDropdownMenu
npx shadcn@latest add dropdown-menuInput / Select / Textarea
npx shadcn@latest add input select textareaEnter your email address.
Table / DataTable
npx shadcn@latest add table| Invoice | Status | Method | Amount | |
|---|---|---|---|---|
| INV001 | Paid | Credit Card | ¥250,000 | |
| INV002 | Pending | PayPay | ¥150,000 | |
| INV003 | Unpaid | Bank Transfer | ¥350,000 |
Skeleton / Loading States
npx shadcn@latest add skeletonCard Skeleton
Button Loading
Toast / Sonner
npx shadcn@latest add sonnerEvent Created
Sunday, December 03, 2024
Success
Your changes have been saved.
Error
Something went wrong.
Tabs
npx shadcn@latest add tabsOverview content goes here.
Pagination
npx shadcn@latest add paginationPage 1 of 5
Command (⌘K)
npx shadcn@latest add commandAlert
npx shadcn@latest add alertInfo
This is an informational message.
Warning
Please review before proceeding.
Error
Something went wrong. Please try again.
Breadcrumb
npx shadcn@latest add breadcrumbAvatar
npx shadcn@latest add avatarJohn Doe
Admin
Sheet (Side Panel)
npx shadcn@latest add sheetProgress
npx shadcn@latest add progressSidebar (Official 25+ Components)
npx shadcn@latest add sidebar
"I don't like building sidebars. So I built 30+ of them." — shadcn
Content Area
Charts & Data Visualization
Recharts (推奨ライブラリ)
npm install rechartsLine Chart(売上推移)
Bar Chart(商品別売上)
Pie Chart(カテゴリ別)
Area Chart(アクセス数)
推奨ライブラリ
rechartsReact向け、shadcn/ui公式推奨
@tremor/reactダッシュボード特化
chart.js軽量、汎用
Advanced Data Table (TanStack Table)
TanStack Table + shadcn/ui
npm install @tanstack/react-table| ステータス | |||||
|---|---|---|---|---|---|
| IMG-001 | 春ツアー A | 公開中 | ¥156,000 | ||
| IMG-002 | 春ツアー B | 公開中 | ¥77,000 | ||
| IMG-003 | オフショット | 下書き | ¥0 | ||
| IMG-004 | MVカット A | 公開終了 | ¥234,000 |
4件中 1-4件を表示
TanStack Table 主要機能
Blocks (Ready-made Layouts)
Dashboard
10+KPIカード、チャート、テーブル
Authentication
8+ログイン、登録、パスワードリセット
Settings
6+プロフィール、通知、請求
Sidebar
25+各種サイドバーレイアウト
Calendar
30+日/週/月表示、イベント管理
Data Table
5+ソート、フィルター、ページネーション
インストール: npx shadcn@latest add "https://ui.shadcn.com/r/dashboard-01"
UX Patterns
File Upload / Dropzone
ドラッグ&ドロップ対応のファイルアップロード
Dropzone
ファイルをドロップ
またはクリックして選択
PNG, JPG, GIF (max 10MB)
Upload Queue
photo_001.jpg
photo_002.jpg
photo_003.jpg
Empty State
データがない場合のUI
データがありません
まだ登録されたデータがありません
検索結果なし
条件に一致する結果がありません
画像がありません
画像をアップロードしてください
Error States & Validation
フォームバリデーションとエラー表示
Input Validation
有効なメールアドレスを入力してください
利用可能なユーザー名です
Alert Messages
エラーが発生しました
リクエストの処理中にエラーが発生しました。もう一度お試しください。
注意
この操作は取り消すことができません。
保存しました
変更が正常に保存されました。
Validation Best Practices
- • リアルタイムバリデーションで即座にフィードバック
- • エラーメッセージは具体的で行動可能に
- • 必須フィールドは * で明示
- • 成功状態は緑のチェックマークで表示
- • エラー時は border-destructive + text-destructive
- • フォーム送信前にすべてのエラーを表示
Typography
Text Hierarchy
一貫したテキスト階層
H1: Page Title text-4xl font-extrabold
H2: Section Title text-3xl font-semibold
H3: Subsection text-2xl font-semibold
H4: Card Title text-xl font-semibold
Body (Default): The quick brown fox jumps over the lazy dog.text-base leading-7
Muted: Secondary text with muted color.text-sm text-muted-foreground
Small: Fine print and helper text.text-xs text-muted-foreground
Large: Emphasized body texttext-lg font-semibold
Inline Codefont-mono bg-muted rounded
"Blockquote: A quotation or highlighted text."border-l-2 pl-6 italicSpacing & Layout
Spacing Scale
xssmmdlgxl2xlBorder Radius
rounded-nonerounded-smrounded-mdrounded-lgrounded-xlrounded-fullMotion & Animation
Duration Scale
一貫した動きのタイミング
instant75msホバー、フォーカス変化
fast150msボタン、トグル、ドロップダウン
normal200msモーダル、シート、パネル
slow300msページ遷移、大きな要素
Easing Functions
自然な動きのための曲線
ease-outcubic-bezier(0, 0, 0.2, 1)
要素の出現(デフォルト)
ease-in-outcubic-bezier(0.4, 0, 0.2, 1)
位置移動、変形
ease-incubic-bezier(0.4, 0, 1, 1)
要素の退出
Animation Patterns
コンポーネント別アニメーション
Button Hover
transition-colors duration-150bg-primary/10 → bg-primary/20
Modal Enter
animate-in fade-in-0 zoom-in-95opacity 0→1, scale 0.95→1
Sheet Slide
animate-in slide-in-from-righttranslateX 100% → 0
Dropdown
animate-in fade-in-0 zoom-in-95opacity + scale
Tailwind CSS v4 Animation Classes
animate-in, animate-out, fade-in-0, fade-out-0, zoom-in-95, zoom-out-95, slide-in-from-top, slide-in-from-bottom, slide-in-from-left, slide-in-from-rightResponsive Breakpoints
Tailwind CSS Breakpoints
モバイルファーストのレスポンシブ設計
sm:小型タブレット、横向きモバイル
2カラム、小さなカード
md:タブレット
サイドバー表示、3カラム
lg:小型デスクトップ、大型タブレット
フル機能サイドバー
xl:デスクトップ
4カラム、広いコンテンツ
2xl:大型デスクトップ
最大幅コンテナ
Container Max Widths
max-w-md: 448px(フォーム)
max-w-2xl: 672px(コンテンツ)
max-w-4xl: 896px(ダッシュボード)
max-w-7xl: 1280px(フルレイアウト)
Usage Example
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"><aside className="hidden md:block w-64 lg:w-72">Dark Mode Support
Theme Toggle
CSS変数による自動テーマ切り替え
Dashboard
Admin Panel
Revenue
¥2.4M
Orders
1,234
Users
5,678
CSS変数を使用することで、ダークモードは自動的に対応されます。
globals.css - Dark Mode Variables
.dark {
--background: 240 10% 3.9%;
--foreground: 0 0% 98%;
--card: 240 10% 3.9%;
--card-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 240 5.9% 10%;
--muted: 240 3.7% 15.9%;
--muted-foreground: 240 5% 64.9%;
--border: 240 3.7% 15.9%;
}Do's and Don'ts
- • CSS変数(
bg-primary)を使う - • 公式コンポーネントをそのまま使う
- • Radix UIのアクセシビリティを活用
- •
ring-offset-backgroundでフォーカス表示 - • Sonner でトースト通知
- • TanStack Table でDataTable
- • 直接色を指定(
bg-slate-900)しない - • コンポーネントを自作しない
- •
outline-none単独で使わない - • alert() や confirm() を使わない
- • ブランドカラーを持ち込まない
- • グラデーションを使わない
Required Components (Install All)
npx shadcn@latest addalertalert-dialogavatarbadgebreadcrumbbuttoncalendarcardcheckboxcommanddate-pickerdialogdropdown-menuinputlabelpaginationpopoverprogressradio-groupselectseparatorsheetsidebarskeletonsonnertabletabstextareatooltipOne-liner: npx shadcn@latest add alert alert-dialog avatar badge breadcrumb button calendar card checkbox command date-picker dialog dropdown-menu input label pagination popover progress radio-group select separator sheet sidebar skeleton sonner table tabs textarea tooltip
Quick Reference
Key Principles
- • CSS変数でテーマを統一
- • 公式コンポーネントを優先
- • Radix UIでアクセシビリティ確保
- • モノクロ基調、色は状態のみ
- • コンポジションで柔軟に構築