DESIGN.md 将机器可读的设计令牌与人类可读的设计原理相结合,为智能体提供持久化、结构化的设计系统理解。
npx @google/design.md lint DESIGN.md
---
name: Heritage
colors:
primary: "#1A1C1E"
secondary: "#6C7278"
tertiary: "#B8422E"
neutral: "#F7F5F2"
typography:
h1:
fontFamily: Public Sans
fontSize: 3rem
---
建筑极简主义与新闻庄重感相结合。DESIGN.md 文件将机器可读的设计令牌(YAML 前置事项)与人类可读的设计原理(Markdown 正文)相结合。令牌提供精确值,正文解释这些值存在的原因以及如何应用它们。
YAML 令牌层 + Markdown 原理层,结构化设计系统。
颜色、排版、间距、圆角——所有设计决策均可量化。
导出为 Tailwind 主题或 W3C DTCG 令牌格式。
验证规范合规性、捕获损坏引用、检查 WCAG 对比度——所有操作均可通过 CLI 完成。
检查结构正确性、对比度比率和令牌引用。
npx @google/design.md lint DESIGN.md
检测令牌级别和正文回归。
npx @google/design.md diff DESIGN.md DESIGN-v2.md
输出为 Tailwind 主题或 W3C DTCG 格式。
npx @google/design.md export --format tailwind DESIGN.md
DESIGN.md 由两层构成:YAML 前置事项承载机器可读令牌,Markdown 正文承载人类可读原理。
version: <string> # 可选,当前: "alpha"
name: <string>
description: <string> # 可选
colors:
<token-name>: <Color>
typography:
<token-name>: <Typography>
rounded:
<scale-level>: <Dimension>
spacing:
<scale-level>: <Dimension | number>
components:
<component-name>:
<token-name>: <string | token reference>
components:
button-primary:
backgroundColor: "{colors.tertiary}"
textColor: "{colors.on-tertiary}"
rounded: "{rounded.sm}"
padding: 12px
button-primary-hover:
backgroundColor: "{colors.tertiary-container}"
sRGB 十六进制格式
#1A1C1E
数字 + 单位
48px · -0.02em · 3rem
引用其他令牌
{colors.primary}
字体族、大小、字重
fontFamily · fontSize …
主色
#1A1C1E · 深墨色
次色
#6C7278 · 石板灰
第三色
#B8422E · 波士顿陶土
中性色
#F7F5F2 · 温暖石灰岩
$ npx @google/design.md lint DESIGN.md
$ npx @google/design.md lint --format json DESIGN.md
$ cat DESIGN.md | npx @google/design.md lint -
位置参数 · 必需 · 文件路径或 -
json · 默认: json
有错误返回 1,否则 0
$ npx @google/design.md diff DESIGN.md DESIGN-v2.md
位置参数 · 必需 · "之前" 路径
位置参数 · 必需 · "之后" 路径
检测到回归返回 1
$ npx @google/design.md export --format tailwind DESIGN.md
$ npx @google/design.md export --format dtcg DESIGN.md
$ npx @google/design.md spec
$ npx @google/design.md spec --rules
$ npx @google/design.md spec --rules-only --format json
| 规则 | 严重级别 | 检查内容 |
|---|---|---|
broken-ref |
错误 | 令牌引用无法解析为任何已定义令牌 |
missing-primary |
警告 | 颜色已定义但不存在 primary 颜色 |
contrast-ratio |
警告 | 组件对比度低于 WCAG AA 最低标准 (4.5:1) |
orphaned-tokens |
警告 | 颜色令牌已定义但未被任何组件引用 |
token-summary |
信息 | 每个章节中定义的令牌数量摘要 |
missing-sections |
信息 | 可选章节(间距、圆角)缺失 |
missing-typography |
警告 | 颜色已定义但不存在排版令牌 |
section-order |
警告 | 章节出现在规范定义的规范顺序之外 |
import { lint } from '@google/design.md/linter';
const report = lint(markdownString);
console.log(report.findings); // Finding[]
console.log(report.summary); // { errors, warnings, info }
console.log(report.designSystem); // Parsed DesignSystemState
DESIGN.md 消费者遇到未知内容时的标准行为定义,确保向前兼容性。
受 W3C 设计令牌格式启发,DESIGN.md 令牌可无缝转换为主流格式。
导出为 Tailwind CSS 主题配置,直接在项目中使用设计令牌。
export --format tailwind
W3C 设计令牌格式模块标准,实现跨平台设计令牌互操作。
export --format dtcg