@oods/tokens

中文文档
0.11.3发布于 2026/11/02Apache-2.0TypeScriptESM + CJS零依赖

Design tokens for OODS Foundry: CSS variables and JavaScript values for its brands in light, dark and high-contrast themes.

原始使用文档
文档目录4 节
  1. Install
  2. First result
  3. Limits
  4. License

@oods/tokens

CSS variables and JavaScript token values used by OODS components. The built package contains the shipped brands and their light, dark and high-contrast scopes. It does not run an MCP server.

Install

npm install @oods/tokens

First result

In a bundler-based app, import the stylesheet once and choose a scope on the document:

import '@oods/tokens/css';
document.documentElement.dataset.brand = 'A';
document.documentElement.dataset.theme = 'light';

Use a semantic role in your CSS:

body {
  background: var(--sys-surface-canvas);
  color: var(--sys-text-primary);
}

For JavaScript values:

import tokens from '@oods/tokens';
console.log(tokens.cssVariablesByScope.A.light['--oods-sys-surface-canvas']); // oklch(1 0 286)

A scope works on any element, not only the document: a panel with its own data-brand and data-theme gets that brand's and theme's roles, so a dark preview can sit in a light page.

The stylesheet also declares the three typefaces the tokens name: Geist, Geist Mono and DM Sans. Their files ship in dist/fonts and load from beside the stylesheet, never from the network; a browser fetches one only for text that uses the family. Vite copies them with the stylesheet; esbuild needs a loader for them (--loader:.woff2=file), and webpack an asset rule for .woff2.

cssVariablesByScope holds every variable of each brand and theme with its value resolved, keyed by its full name, which begins with --oods-. The stylesheet uses the short name: --oods-sys-surface-canvas in JavaScript is the value var(--sys-surface-canvas) takes under data-brand="A" and data-theme="light".

@oods/tokens/brands exports the brands in this build. @oods/tokens/tailwind exports the built JSON token payload; it does not install or configure Tailwind for you.

To turn your colour tokens into an OODS Foundry brand, use brand_create through @oods/foundry and its shipped QUICKSTART.md. A generated app for that brand carries a separate stylesheet containing its custom scopes.

Limits

Generated apps pin the OODS release that generated them; to upgrade, regenerate the app or move all four pins together. These packages are separate from the local MCP server, @oods/foundry.

License

Apache License 2.0. See LICENSE and NOTICE. The Geist, Geist Mono and DM Sans font files are under the SIL Open Font License 1.1, and the colour calibration derived from Radix Colors (dist/radix-calibration.json) is under the MIT License; NOTICE carries those licences and where the files come from. Generated output belongs to its user; installed package dependencies retain their own licenses.

版本与发布记录

@oods/tokens 共发布 25 个版本,首次发布于 2026/09/26;过去 12 个月发布了 25 个版本。

版本发布日期距今
0.11.3latest2026/11/021 天前
0.11.22026/10/1123 天前
0.11.12026/10/1023 天前
0.11.02026/10/0925 天前
0.10.22026/10/0925 天前
0.10.12026/10/0825 天前

关于 @oods/tokens 的常见问题

@oods/tokens 是什么?

为OODS Foundry设计标记:其品牌在浅色,深色和高对比度主题中的CSS变量和JavaScript值。

如何安装 @oods/tokens?

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

@oods/tokens 支持 TypeScript 吗?

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

@oods/tokens 支持 ESM 还是 CommonJS?

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

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

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

@oods/tokens 可以商用吗?

@oods/tokens 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@oods/tokens 还在维护吗?

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