@bcc-code/design-tokens

中文文档
5.2.13发布于 2026/10/26MITTypeScriptES Module零依赖近 30 天下载 2079

Design tokens build system

原始使用文档
文档目录8 节
  1. Installation
  2. Documentation
  3. Quick Links
  4. Adding Component Tokens
  5. Repository Structure
  6. Generated folders
  7. export-tokens/
  8. License

@bcc-code/design-tokens

Design tokens for the BCC Design System. Provides colors, typography, spacing, and component theming for CSS, Tailwind v4, and PrimeVue with light/dark mode support.

Installation

npm install @bcc-code/design-tokens

Documentation

For usage instructions, component guidelines, and examples, see the full documentation:

developer.bcc.no/bcc-design

Adding Component Tokens

When designers add or update PrimeVue component tokens via Figma:

  1. Export from Figma — Component tokens land in tokens/aura/component.json
  2. Add theme overrides (recommended) — For light/dark differentiation, add the component to both tokens/aura/component/light.json and tokens/aura/component/dark.json. Without these, the component will use the same tokens in both themes.
  3. Run the build — pnpm build
  4. Check warnings — The build will warn about components missing theme overrides

Component tokens are automatically picked up from component.json — no manual list to maintain.

For BCC-specific layout/sizing overrides (not from Figma), add them to MANUAL_COMPONENT_OVERRIDES in export-tokens/constants.js.

Repository Structure

Generated folders

  • tokens/ is generated from Figma token exports (source of truth from design).
  • build/ is generated by running the build script (pnpm build / node export-tokens/build.js).
  • Do not hand-edit files in build/; regenerate instead.

export-tokens/

  • export-tokens/build.js
    Main build orchestrator. Runs validation, builds token outputs, combines theme files, generates types, and generates PrimeVue config.

    • Can edit? Yes, when changing build flow or adding new outputs.
  • export-tokens/constants.js
    Central configuration for paths, token group lists, Tailwind mappings/utilities, known exceptions, and manual component overrides.

    • Can edit? Yes. This is the primary file to update when adding token groups, mappings, or BCC manual overrides.
  • export-tokens/sd-formats.js
    Registers custom Style Dictionary transforms/formats (JS with refs, CSS variables, Tailwind utilities).

    • Can edit? Yes, if you need to change output format behavior.
  • export-tokens/primevue-config.js
    Generates build/primevue/config.js from built tokens + the Aura preset (@primeuix/themes/aura) and applies override logic/validation.

    • Can edit? Yes, for PrimeVue mapping/resolution logic changes.
  • export-tokens/validation.js
    Validates light/dark token symmetry and warns about missing component theme overrides.

    • Can edit? Yes, when adjusting validation rules.
  • export-tokens/bcc-build.js
    Creates combined tokens.css and tailwind.css from generated light/dark outputs.

    • Can edit? Yes, if combined output strategy needs to change.
  • export-tokens/type-gen.js
    Generates .d.ts module declarations for published CSS files.

    • Can edit? Yes, when changing published type declarations.

License

MIT

版本与发布记录

@bcc-code/design-tokens 共发布 202 个版本,首次发布于 2023/03/07;过去 12 个月发布了 118 个版本。

版本发布日期距今
5.2.13latest2026/10/2613 天前
5.2.122026/10/1226 天前
5.2.112026/09/291 个月前
5.2.102026/09/221 个月前
5.2.92026/09/151 个月前
5.2.82026/09/091 个月前

其他发布通道:dev → 0.0.0-dev.c96d6e2。

关于 @bcc-code/design-tokens 的常见问题

@bcc-code/design-tokens 是什么?

Design tokens build system

如何安装 @bcc-code/design-tokens?

在项目目录运行 npm install @bcc-code/design-tokens,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@primeuix/themes(^2.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bcc-code/design-tokens 支持 TypeScript 吗?

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

@bcc-code/design-tokens 支持 ESM 还是 CommonJS?

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

@bcc-code/design-tokens 需要什么版本的 Node.js?

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

@bcc-code/design-tokens 可以商用吗?

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

@bcc-code/design-tokens 的下载量有多少?

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

@bcc-code/design-tokens 还在维护吗?

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