@cueplusplus/tokens

中文文档
0.34.2发布于 2026/11/09MITTypeScriptES Module零依赖近 30 天下载 4232

DTCG design tokens for the CUE++ design system: 5 density levels and 8 font pairings, compiled to attribute-scoped CSS custom properties. Colour lives in a theme package.

原始使用文档
文档目录4 节
  1. Install
  2. Quick start
  3. What it ships
  4. Where the rest is

@cueplusplus/tokens

The token layer under @cueplusplus/ui, for an app that needs the vocabulary by name rather than through a component: five density rungs, fourteen font pairings, fourteen style sets and ten paint packs, authored as DTCG source and compiled to attribute-scoped CSS custom properties.

Four of the system's five DOM axes live here, and they own strictly disjoint token sets — a page is one choice on each, so they compose as a sum rather than a product:

axisowns
[data-density]geometry — control heights, radii, spacing, type sizes
[data-font]the three type stacks a pairing names
[data-style]page composition — prose and UI leading, measures, band rhythm, rules and grounds, caps tracking (13 names)
[data-paint]the finish — rims, strokes, elevation, glow, glass, texture, edge fades (18 names and 13 inks); off until a page stamps it

Colour is not here. The fifth axis, [data-theme], left this package: a palette is a package of its own now (@cueplusplus/theme-<name>, and anybody else's), so there is no THEMES export, no ThemeName, and dist/theme.css is a deprecated alias of axes.css — kept through 0.10, and removed in the minor after. The blank palette an unstamped page paints lives in @cueplusplus/theme-base.

Install

The @cueplusplus scope is public on npm and resolves there by default, so there is nothing to configure and no credential to supply — it installs like any other package.

pnpm add @cueplusplus/tokens

No peers and no dependencies: this package is generated data and eight lines of JavaScript. It also arrives as a dependency of @cueplusplus/ui, so an app that installs the components already has it — naming it in package.json just makes the constants importable in your own code.

CI, Vercel and the token's expiry are in docs/CONSUMING.md §1.

Quick start

An app importing @cueplusplus/ui/styles.css already has the axes as CSS; it needs this package by name only to stop restating what it exports.

import { DENSITIES, token } from "@cueplusplus/tokens";

const ring = `1px solid ${token("focus")}`; // "1px solid var(--cue-focus)"
const labels = DENSITIES.map((rung) => [rung, rung.replace(/-/g, " ")] as const);

DENSITIES is ["ultra-compact", "compact", "normal", "large", "ultra-large"], in ladder order. Derive a picker's labels and a stylesheet's rung list from it rather than writing either out: both go stale silently when the ladder changes, and nothing anywhere reports it. The same holds for the other three axes — FONTS, STYLE_SETS and PAINTS are each the full vocabulary in menu order, and a picker built from one grows with the catalogue instead of silently missing its newest entry.

Without a bundler, the same thing in CSS is one import:

@import "@cueplusplus/tokens/axes.css";

What it ships

subpathwhat it is
@cueplusplus/tokensthe four axis vocabularies — DENSITIES, FONTS, STYLE_SETS, PAINTS — with MODES and every DEFAULT_*; the contracts each axis owns (COLOR_CONTRACT, GEOMETRY_CONTRACT, FONT_TOKENS, STYLE_CONTRACT, STYLE_SET_CONTRACT, PAINT_CONTRACT, PAINT_INK_CONTRACT, PAINT_INKS); FONT_PAIRINGS and FONT_FACES; faceProperty() and token(); and a type for each
./axes.cssthe density, font, style-set and paint axes as CSS — every [data-density], [data-font], [data-style] and [data-paint] block — with no colour in them
./tailwind.cssthe Tailwind v4 @theme inline mapping layer
./theme.cssa deprecated alias of ./axes.css: kept through 0.10, removed in the minor after
./base.jsonthe same axes as data, for a theme built outside this build
./primitives.tokens.jsonthe tier-1 palette a theme source aliases
./registry/token-layer.jsonthe theme-independent half of the layer as a shadcn fragment — folded into a registry base item, not installable on its own

The root entry is dist/tokens.js with dist/tokens.d.ts beside it — plain JavaScript, because Node refuses to strip types for anything under node_modules and a .ts entry is one a registry consumer cannot load.

Everything here is generated by build.mjs from src/**.tokens.json. Edit the sources, never dist/.

Where the rest is

版本与发布记录

@cueplusplus/tokens 共发布 46 个版本,首次发布于 2026/09/16;过去 12 个月发布了 46 个版本。

版本发布日期距今
0.34.2latest2026/11/092 天前
0.34.12026/10/2715 天前
0.34.1-dev.1793042906377dev2026/10/2715 天前
0.34.02026/10/2615 天前
0.34.0-dev.17930064848772026/10/2615 天前
0.33.02026/10/2615 天前

其他发布通道:historical → 0.12.0,dev → 0.34.1-dev.1793042906377。

关于 @cueplusplus/tokens 的常见问题

@cueplusplus/tokens 是什么?

DTCG design tokens for the CUE++ design system: 5 density levels and 8 font pairings, compiled to attribute-scoped CSS custom properties. Colour lives in a theme package.

如何安装 @cueplusplus/tokens?

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

@cueplusplus/tokens 支持 TypeScript 吗?

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

@cueplusplus/tokens 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cueplusplus/tokens 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cueplusplus/tokens 可以商用吗?

@cueplusplus/tokens 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cueplusplus/tokens 的下载量有多少?

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

@cueplusplus/tokens 还在维护吗?

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