Tailwind CSS 與 shadcn/ui
將 DESIGN.md 與產生的 CSS Token 配對使用,可確保 Agent 選用正確的語意類別,同時讓瀏覽器在渲染階段強制套用精確的數值。DesignMD Pro 執行三個純用戶端產生器來輸出樣式表。
Tailwind CSS v4(@theme)
開啟 Tailwind v4 主題產生器 並貼上任何 DESIGN.md。產生器會讀取您的 frontmatter Token 對應表,並輸出可直接用於 globals.css 的 CSS:
DESIGN.md Token 群組 | 輸出的 CSS 內容 |
|---|---|
colors.<key> | @theme 內的 --color-<key>: <hex>; |
colors.light.<key> | @theme 內的 --color-<key>: <hex>;(基礎主題) |
colors.dark.<key> | .dark 內的 --color-<key>: <hex>; |
typography 字體家族 | --font-sans(第一個字體家族)、--font-sans-2… |
typography 字級比例 | --text-<key> 與 --text-<key>--line-height |
rounded.<key> | --radius-<key>: <dim>; |
spacing.<key> | --spacing-<key>: <dim>; |
輸出範例:
@theme {
--color-primary: #4338ca;
--color-background: #ffffff;
--color-surface: #f6f5f4;
--color-text: #18181b;
--font-sans: "Inter", sans-serif;
--text-body-md: 16px;
--text-body-md--line-height: 1.6;
--radius-md: 8px;
--spacing-md: 16px;
}
.dark {
--color-primary: #818cf8;
--color-background: #0f172a;
}原生 CSS 變數
CSS 變數產生器 會輸出與框架無關的 :root 與 .dark 自訂屬性:
colors.<key>→--<key>: <hex>;(colors.dark.*則置於.dark中)typography.<key>→--font-<key>、--font-<key>-size、--font-<key>-weight、--font-<key>-line-heightrounded.<key>→--radius-<key>spacing.<key>→--spacing-<key>
shadcn/ui 語意對應
shadcn 主題產生器 使用語意鍵名比對(依序評估,每個變數以最先符合者為準),將 DESIGN.md 色彩鍵對應至 shadcn 的標準 CSS 變數:
| Token 鍵名模式 | shadcn CSS 變數 |
|---|---|
background, canvas, page, bg | --background |
surface, card, popover, elevated | --card |
primary, brand | --primary |
on-primary, onprimary, primary-foreground | --primary-foreground |
secondary | --secondary |
muted, subtle, disabled | --muted |
accent, tertiary | --accent |
destructive, error, danger | --destructive |
border, outline, divider, stroke | --border |
ring, focus | --ring |
text, foreground, fg, heading, body | --foreground |
| 任何未符合的鍵名 | --color-<key> |
針對圓角半徑,產生器會將 rounded.md(若無則退回 rounded.base 或 rounded.default)對應至 --radius。巢狀的 colors.dark.* 鍵也會在 .dark 中套用相同的語意對應規則。
Tip
將鍵命名為 background、surface、primary、on-primary、text、muted 與 border(如完整範例所示),無需額外設定即可讓 shadcn 主題對應器與 WCAG 對比度驗證器正常運作。
下一步
- Token 命名規範 — 最佳化程式碼產生與 Lint 準確度的命名模式
- 設計 Token — 巢狀
light/darkToken 對應表的詳細說明 - Vercel v0 與 Bolt — 將產生的 CSS 結合瀏覽器 UI 建置工具工作流程
Last updated on