@appdirect/ad-design-tokens

中文文档
0.0.19发布于 2026/11/06UNLICENSEDES Module零依赖近 30 天下载 3282

AppDirect design token source and distribution artifacts.

原始使用文档
文档目录9 节
  1. Install
  2. Available Exports
  3. Usage
  4. Figma via Tokens Studio
  5. Resolved JSON imports
  6. CSS variables — vanilla consumers
  7. CSS variables — palette only
  8. CSS variables — Mantine adapter
  9. JS entrypoint

@appdirect/ad-design-tokens

AppDirect design tokens for frontend applications.

Install

npm install @appdirect/ad-design-tokens

Available Exports

  • Resolved semantic tokens:
    • @appdirect/ad-design-tokens/semantic/light
    • @appdirect/ad-design-tokens/semantic/dark
  • Resolved component tokens:
    • @appdirect/ad-design-tokens/components/light
    • @appdirect/ad-design-tokens/components/dark
  • Resolved token outputs (per layer):
    • @appdirect/ad-design-tokens/resolved/core.json
    • @appdirect/ad-design-tokens/resolved/open-color.json
    • @appdirect/ad-design-tokens/resolved/derived.json
    • @appdirect/ad-design-tokens/resolved/semantic-light.json
    • @appdirect/ad-design-tokens/resolved/semantic-dark.json
    • @appdirect/ad-design-tokens/resolved/components-light.json
    • @appdirect/ad-design-tokens/resolved/components-dark.json
  • Figma / Tokens Studio (DTCG JSON with {ref} aliases intact):
    • @appdirect/ad-design-tokens/figma/open-color.json
    • @appdirect/ad-design-tokens/figma/core.json
    • @appdirect/ad-design-tokens/figma/derived.json
    • @appdirect/ad-design-tokens/figma/semantic.light.json
    • @appdirect/ad-design-tokens/figma/semantic.dark.json
    • @appdirect/ad-design-tokens/figma/components.light.json
    • @appdirect/ad-design-tokens/figma/components.dark.json
    • @appdirect/ad-design-tokens/figma/$themes.json (Tokens Studio theme manifest)
  • CSS variables:
    • @appdirect/ad-design-tokens/css/foundations.css (semantic tokens only — base for framework adapters)
    • @appdirect/ad-design-tokens/css/mantine.css (Mantine adapter — component selectors referencing --ad-* vars)
    • @appdirect/ad-design-tokens/css/tokens.css (foundations + component tokens — full monolith for vanilla consumers)
    • @appdirect/ad-design-tokens/css/open-color.css (--ad-open-color-* palette)
  • Design docs adapter:
    • @appdirect/ad-design-tokens/design-spec.yaml (resolved YAML payload for syncing DESIGN.md front matter in ad-design-system)
  • JS entrypoint:
    • @appdirect/ad-design-tokens (full resolved bundle)

Usage

Figma via Tokens Studio

Point Tokens Studio at dist/figma/ in the published package. The $themes.json manifest groups the layer files into two themes (Light, Dark) so Tokens Studio creates the following Figma variable collections on import:

CollectionModes
Tokens / Open-ColorValue
Tokens / CoreValue
Tokens / DerivedValue
Tokens / SemanticLight, Dark
Tokens / Semantic BrandValue
Tokens / ComponentsLight, Dark

Interactive states (hover, active, focus, disabled) are intentionally excluded from the Figma export — they are code-side concerns. Figma binds the default/resting state only.

Resolved JSON imports

import semanticLight from '@appdirect/ad-design-tokens/semantic/light' with { type: 'json' };
import componentsDark from '@appdirect/ad-design-tokens/components/dark' with { type: 'json' };
import resolvedCore from '@appdirect/ad-design-tokens/resolved/core.json' with { type: 'json' };

CSS variables — vanilla consumers

import '@appdirect/ad-design-tokens/css/tokens.css';

CSS variables — palette only

import '@appdirect/ad-design-tokens/css/open-color.css';

CSS variables — Mantine adapter

Import after @mantine/core/styles.css so the adapter's higher-specificity selectors win:

import '@mantine/core/styles.css';
import '@appdirect/ad-design-tokens/css/foundations.css';
import '@appdirect/ad-design-tokens/css/mantine.css';
.button {
  background: var(--ad-color-brand-primary);
  color: var(--ad-color-brand-on-primary);
}

JS entrypoint

import tokens from '@appdirect/ad-design-tokens';

console.log(tokens.semantic.light.color.bg.default.$value);

版本与发布记录

@appdirect/ad-design-tokens 共发布 20 个版本,首次发布于 2026/10/14;过去 12 个月发布了 20 个版本。

版本发布日期距今
0.0.19latest2026/11/062 天前
0.0.182026/10/318 天前
0.0.172026/10/2811 天前
0.0.162026/10/2711 天前
0.0.152026/10/2712 天前
0.0.142026/10/2712 天前

关于 @appdirect/ad-design-tokens 的常见问题

@appdirect/ad-design-tokens 是什么?

AppDirect design token source and distribution artifacts.

如何安装 @appdirect/ad-design-tokens?

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

@appdirect/ad-design-tokens 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/appdirect__ad-design-tokens 是否存在。

@appdirect/ad-design-tokens 支持 ESM 还是 CommonJS?

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

@appdirect/ad-design-tokens 可以商用吗?

@appdirect/ad-design-tokens 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@appdirect/ad-design-tokens 的下载量有多少?

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

@appdirect/ad-design-tokens 还在维护吗?

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