Figma 與設計 Token
Figma Variables 與 W3C Design Tokens(tokens.json / Tokens Studio)儲存的是機器可讀的基礎 Token,而 DESIGN.md 則補上了 AI 程式設計 Agent 組裝真實頁面所需的散文判斷依據與反向約束。
將 Figma 概念對應至 DESIGN.md
| Figma 概念 | DESIGN.md 對應項目 |
|---|---|
| Color Variables(Light / Dark) | colors 與 colors.dark.* 十六進位 Token |
| Number Variables(Radius) | rounded(sm、md、lg、full) |
| Number Variables(Spacing) | spacing(xs、sm、md、lg、xl) |
| Text Styles | typography 項目(fontFamily、fontSize、fontWeight、lineHeight、letterSpacing) |
| 元件規範與使用說明 | components YAML 屬性與 ## Components 散文 |
| 設計評析與品牌規範 | ## Overview、## Voice & Content Strategy、## Do's and Don'ts |
將 DTCG tokens.json 橋接至 DESIGN.md
若您的設計團隊從 Figma 或 Tokens Studio 匯出 W3C DTCG JSON:
{
"color": {
"primary": { "$type": "color", "$value": "#4338ca" },
"surface": { "$type": "color", "$value": "#f6f5f4" }
},
"dimension": {
"radius-md": { "$type": "dimension", "$value": "8px" }
}
}將扁平化的 Token 鍵轉換為 DESIGN.md frontmatter,並補上 JSON 所缺乏的人類設計理由:
---
version: alpha
name: Product Design System
colors:
primary: "#4338ca"
surface: "#f6f5f4"
background: "#ffffff"
text: "#18181b"
rounded:
md: 8px
---
## Colors
- **Primary (`#4338ca`):** Primary actions and focus rings only.
- **Surface (`#f6f5f4`):** Card and sidebar background on top of white `#ffffff` canvases.選擇單一真實來源
避免在三個地方(Figma、tokens.json 與 DESIGN.md)手動編輯 Token:
- 設計驅動團隊:更新 Figma Variables,在發佈分支上將基礎數值匯出或同步至
DESIGN.mdYAML frontmatter,在 git 中手動維護##散文章節,並在 PR 審查時執行npx @google/design.md diff與lint。 - 程式碼驅動團隊:將 git 中的
DESIGN.md視為單一真實來源,透過 DesignMD Pro 的程式碼產生器從中產生 Tailwind v4 / CSS Variables / shadcn 主題,並在重大版本發佈時同步回 Figma。
驗證同步更新
每當 Figma 更新寫入 DESIGN.md 時:
-
在驗證器中或透過
npx @google/design.md lint DESIGN.md驗證參照完整性與對比度。 -
在合併前檢視確切的 Token 變更:
npx @google/design.md diff origin/main:DESIGN.md DESIGN.md
下一步
- Token 命名規範 — 讓 Figma 變數名稱對齊
DESIGN.md的對比度與程式碼產生啟發式規則 - 版本控制與修訂 — 跨版本追蹤設計更新
- Tailwind CSS 與 shadcn/ui 整合 — 將 Token 匯出回 CSS
Last updated on