@biom3/design-tokens

中文文档
0.4.8发布于 2025/08/12Apache-2.0TypeScriptES Module近 30 天下载 2762

BIOM3-textured-logos-10

原始使用文档
文档目录3 节
  1. What's inside?
  2. Using the ts const design tokens:
  3. Using the css-variable design-tokens:

BIOM3-textured-logos-10

@biom3/design-tokens

This package publishes via CICD to the public npm component: @biom3/design-tokens. To read more, see the theming & tokenisation proposal document.

To see an overview of the entire design-tokens taxonomy, see this document.

What's inside?

Through this component we expose our complete library of BIOME design tokens. They are made available for use as both:

  1. exported typescript consts, and
  2. css variable definitions inside of importable css files

Using the ts const design tokens:

To use the typescript design-tokens, simply import them from the root of the pacakge. For example:

import { base } from '@biom3/design-tokens';

BIOME's default colour scheme is onLight. Therefore, when you import the base, or onLightBase design-tokens, you will get ONLY the onLight colors and gradients.

To use these design-token variables inside bespoke react typescript components:

import {
  onDarkBase,
  onLightBase,
  smartPickTokenValue,
} from '@biom3/design-tokens';
const DemoComponent = () => (
  <div
    style={{
      fontSize: onLightBase.text.body.medium.regular.fontSize,
      color: smartPickTokenValue(onDarkBase, 'base.color.brand.1'),
    }}
  >
    test component text
  </div>
);

Using the css-variable design-tokens:

All the BIOME design-tokens can be imported and used as simple css-variables, by importing css files from your App code. For example:

import '@biom3/design-tokens/css/base-onLight.global.css'; // contains all "onLight" BASE design-tokens
// import "@biom3/design-tokens/css/base-onDark.global.css"; // contains all "onDark" BASE design-tokens
import '@biom3/design-tokens/css/text.global.css'; // contains all fonts (@font-face) imports

*@NOTE All css-variable declarations are global styles scoped to the body selector, thus the base design-token files will overwrite each other, so you should only use 1 base design-token css file at a time. Choose the theme css file based on whether you are planning to display UI in "onDark" or "onLight" (or add your own!).

To see a complete listing of all available design-token css-variables, you can inspect the body element inside your browser's dev tools. For example:

Screenshot 2022-12-07 at 11 32 00 am

Then, to use these css-variable design-tokens:

/* some custom styles.css file: */
@import '@biom3/design-tokens/css/base-onDark.global.css';
@import '@biom3/design-tokens/css/text.global.css';

/* your bespoke item class styles */
.headingText {
  color: var(--base-color-brand-1);
}

版本与发布记录

@biom3/design-tokens 共发布 52 个版本,首次发布于 2022/12/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.4.8latest2025/08/121.2 年前
0.4.72025/02/251.7 年前
0.4.62024/11/271.9 年前
0.4.52024/11/182 年前
0.4.42024/08/132 年前
0.4.32024/08/122 年前

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

如何安装 @biom3/design-tokens?

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

@biom3/design-tokens 支持 TypeScript 吗?

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

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

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

@biom3/design-tokens 可以商用吗?

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

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

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

@biom3/design-tokens 还在维护吗?

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