UI 元件建立技能
shadcn/ui + 設計系統模式
使用時機:建立新的 UI 元件時
重要:先閱讀設計系統
在產生任何 UI 之前:請閱讀 /DESIGN-SYSTEM.md
品質門檻:至少在以下方面達到 9/10:
- 視覺獨特性
- 品牌對齊
- 無障礙性
模式:shadcn/ui 元件
'use client';
import { Card } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
export function MyComponent({ data }: { data: any }) {
return (
<Card className="p-6 border-border-subtle bg-bg-card">
<h2 className="text-xl font-semibold text-text-primary mb-4">
{data.title}
</h2>
<p className="text-text-secondary mb-4">
{data.description}
</p>
<Button variant="default" className="bg-accent-500 hover:bg-accent-600">
操作按鈕
</Button>
</Card>
);
}
設計 Token(必備)
使用這些,而非原始值:
顏色:
bg-bg-card(不要用bg-white)text-text-primary(不要用text-gray-900)accent-500(#ff6b35 橘色)border-border-subtle
間距:
- Tailwind 類別(p-4、mb-6 等)
禁止模式
❌ bg-white(改用 bg-bg-card)
❌ text-gray-600(改用 text-text-secondary)
❌ 無響應式設計的 grid grid-cols-3 gap-4(需加上 md:、lg:)
必備模式
✅ 使用設計系統中的設計 Token ✅ 所有狀態(hover、focus、disabled) ✅ 響應式中斷點 ✅ 無障礙性(aria-labels)
標準:使用設計 Token、實作所有狀態、確保無障礙性