@clay-design-system/tokens

中文文档
0.24.0发布于 2026/11/10TypeScriptESM + CJS零依赖近 30 天下载 2928

Design tokens for the Clay design system, compiled from DTCG JSON sources using Style Dictionary 4.

原始使用文档
文档目录8 节
  1. Tier system
  2. Source structure
  3. Output
  4. Usage
  5. Naming convention
  6. Adding or modifying tokens
  7. Enforcement
  8. Unitless values

@clay-design-system/tokens

Design tokens for the Clay design system, compiled from DTCG JSON sources using Style Dictionary 4.

Tier system

Tokens are organized in a layered hierarchy:

Foundation (base primitives — colors, type, spacing, radius, effects)
  ↓ referenced by
Semantic (purpose-driven tokens — background, text, border, icon, size, motion)
  ↓ referenced by
Web / Platform / Marketing (tier-specific tokens — typography scales, component tokens)

Components consume semantic or tier-specific tokens. The one raw primitive components may use is the brand palette (--clay-foundation-brand-color-*); the stylelint rule below blocks the retired colour names. Prefer semantic radius/spacing over raw --clay-foundation-radius/spacing-* (guideline, not lint-enforced).

Source structure

src/
├── foundation/          Foundation primitives
│   ├── colors.json         Brand color palette → --clay-foundation-brand-color-* — exact Figma "Mode 1" stops (grey, yellow, lime, stone, harvest, orange, magenta, pink, iris, purple, blue, teal, green)
│   ├── typography.json     Font families, weights, size scale
│   ├── spacing.json        18-step spacing scale (0-180)
│   ├── radius.json         10 radius values (none → full)
│   ├── effects.json        Shadow + blur primitives
│   ├── stroke.json         Border width + color
│   └── customer-logos.json Logo surface colors
├── semantic/            Purpose-driven tokens
│   ├── color-primitives.json  Neutrals, greys, brand palette aliases
│   ├── brand.json             Product colors (monday, wm, crm, dev, svc)
│   ├── text.json              7 text color variants
│   ├── icon.json              7 icon color variants
│   ├── background.json        8 background variants + utilities
│   ├── border.json            9 border color variants
│   ├── size.json              Space scale, icon sizes, depth
│   ├── radius.json            Layout/card radius scale + aliases
│   ├── layout.json            Container, grid, section, header, footer
│   ├── effects.json           Shadows, glass, device-frame
│   ├── motion.json            Duration, easing, transitions
│   └── breakpoints.json       Responsive breakpoints
├── web/                 Web tier (marketing surfaces)
│   ├── typography.json     40 text styles (desktop + mobile)
│   ├── button.json         Button: 4 sizes × 4 styles × 4 colors
│   ├── card.json           Card: container, image, size scale
│   ├── input.json          Input: colors, sizes, states
│   ├── toggle.json         Toggle: track, thumb
│   ├── checkbox.json       Checkbox: control, group, square
│   ├── tag.json            Tag: background + dot variants
│   ├── tabs.json           Tabs: triggers, panels, shells
│   └── slider.json         Slider: dots + arrows
├── platform/            Platform tier (product UI)
│   └── typography.json     11 text styles (headlines, labels, captions)
├── marketing/           Marketing tier (campaigns)
│   └── customer-logos.json Logo height + surface colors
└── email/               Email tier (read by @clay-design-system/email at build time)
    └── typography.json     Lifecycle email type scale

Output

pnpm --filter @clay-design-system/tokens build (src/build.ts) writes:

  • dist/tokens.css (@clay-design-system/tokens/css) — every tier as CSS custom properties on :root; aliases stay var() so changes cascade
  • dist/tokens.resolved.css (@clay-design-system/tokens/css-resolved) — the same with literal values
  • dist/tokens.js + .d.ts (@clay-design-system/tokens) — JS constants (used by @clay-design-system/email); dist/index.cjs + .d.cts for require()
  • dist/mq.js / mq.cjs (@clay-design-system/tokens/mq) — mq / breakpoints media-query helpers, ESM and CJS
  • dist/TOKEN_REFERENCE.md — a generated listing of every token

Usage

// In your app entry point:
import '@clay-design-system/tokens/css'

// In component CSS:
.card {
  border-radius: calc(var(--clay-card-radius-value) * 1px);
  padding: calc(var(--clay-card-padding-value) * 1px);
  background: var(--clay-card-background);
}

Naming convention

--clay-{tier?}-{category}-{variant?}-{property}
  • Foundation: --clay-foundation-brand-color-iris-300, --clay-foundation-type-weight-medium
  • Semantic: --clay-color-background-brand-default, --clay-size-space-400, --clay-motion-duration-fast
  • Web: --clay-web-type-large-desktop-size, --clay-btn-primary-black-bg
  • Platform: --clay-platform-type-headline-xl-600-size
  • Component: --clay-card-radius, --clay-input-border-color, --clay-tabs-trigger-font-size

Adding or modifying tokens

  1. Edit or create a .json file in src/{tier}/
  2. Use DTCG format: { "$value": ..., "$type": "..." }
  3. Reference other tokens with {clay.path.to.token} syntax
  4. Run pnpm build — verify dist/tokens.css updated
  5. Check dist/TOKEN_REFERENCE.md for the generated output

Enforcement

The stylelint plugin @clay-design-system/tokens/stylelint-plugin/no-foundation-tokens.js (run by pnpm --filter @clay-design-system/react lint) blocks the retired colour names — --clay-foundation-color-*, --clay-web-color-*, --clay-brand-color-*. It polices the colour layer only.

{
  "plugins": ["@clay-design-system/tokens/stylelint-plugin/no-foundation-tokens.js"],
  "rules": { "clay-ds/no-foundation-tokens": true }
}

Unitless values

Most numeric tokens are unitless. In CSS, multiply by 1px:

padding: calc(var(--clay-size-space-400) * 1px);  /* → 16px */

This allows tokens to be used in calculations without unit conflicts.

Agent-facing token guide (heading tiers, naming, usage rules): skills/web-design-brain/reference/TOKENS.md.

版本与发布记录

@clay-design-system/tokens 共发布 17 个版本,首次发布于 2026/10/13;过去 12 个月发布了 17 个版本。

版本发布日期距今
0.24.0latest2026/11/10今天
0.23.02026/11/064 天前
0.22.02026/10/2218 天前
0.21.02026/10/2218 天前
0.20.12026/10/2119 天前
0.20.02026/10/2020 天前

关于 @clay-design-system/tokens 的常见问题

@clay-design-system/tokens 是什么?

Design tokens for the Clay design system, compiled from DTCG JSON sources using Style Dictionary 4.

如何安装 @clay-design-system/tokens?

在项目目录运行 npm install @clay-design-system/tokens,或使用 pnpm add / yarn add / bun add。

@clay-design-system/tokens 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@clay-design-system/tokens 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@clay-design-system/tokens 可以商用吗?

@clay-design-system/tokens 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@clay-design-system/tokens 的下载量有多少?

根据 npm 官方下载统计,@clay-design-system/tokens 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,928 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@clay-design-system/tokens 还在维护吗?

最新版本 0.24.0 发布于 2026/11/10(今天);至今共发布 17 个版本,其中过去 12 个月发布了 17 个;首次发布于 2026/10/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。