@entur/tokens

中文文档
4.3.1发布于 2026/11/02EUPL-1.2TypeScriptESM + CJS近 30 天下载 3.7万

This package contains all design tokens and design variables used throughout the design system. We are currently in a process to migrate over to a new design variable system based on [Figma Variables](https://help.figma.com/hc/en-us/articles/1533965713538

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. CSS
  4. LESS / SCSS
  5. JavaScript
  6. [For maintainers] Updating design variables
  7. 1. Generate a JSON export
  8. 2. Update JSON file
  9. 3. Build variables

Entur Linje design tokens

This package contains all design tokens and design variables used throughout the design system. We are currently in a process to migrate over to a new design variable system based on Figma Variables.

Since not all values are available as a variable yet and to avoid breaking changes, all previous design tokens will be kept around for a while. These are built from the src/legacy-tokens.ts file.

💡 Looking for the documentation?

Installation

npm install @entur/tokens
# or if you are using Yarn:
yarn add @entur/tokens

Usage

Please refer to the documentation for in-depth usage information.

This package has several main exports:

  • a CSS file with all tokens as kebab-cased CSS properties
  • a SCSS file with all tokens as kebab-cased SCSS variables
  • a LESS file with all tokens as kebab-cased LESS variables
  • a JavaScript file with all tokens as nested objects.

CSS

To use the CSS file, import it into your bundle like so:

import '@entur/tokens/dist/styles.css';

You'll then have access to all design tokens as CSS variables. You can then use them like so:

.custom-box {
  background-color: var(--colors-greys-grey10);
  color: var(--colors-brand-coral);
  font-size: var(--font-sizes-medium);
  margin: var(--space-medium) var(--space-large);
}

Please refer to the design system documentation for which ones are available.

LESS / SCSS

To use the LESS or SCSS files, import it into your LESS or SCSS file. The method is the same:

@import '@entur/tokens/dist/styles.less';
@import '@entur/tokens/dist/styles.scss';

You'll then be able to use the variables in your code as usual.

// LESS
.custom-box {
  background-color: @colors-greys-grey10;
  color: @colors-brand-coral;
  font-size: @font-sizes-medium;
  margin: @space-medium @space-large;
}
// SCSS
.custom-box {
  background-color: $colors-greys-grey10;
  color: $colors-brand-coral;
  font-size: $font-sizes-medium;
  margin: $space-medium $space-large;
}

JavaScript

To use the design tokens in JavaScript, import the ones you need like so:

import { StyleSheet } from 'react-native';
import { colors, breakpoints, fontSizes } from '@entur/tokens';

StyleSheet.create({
  example: {
    fontSize: fontSizes.medium,
    color: colors.brand.coral,
  },
});

px vs rem

These values are mainly provided in pixels. If you need the values in rem instead, add a .rem after the token name, e.g. space.rem.large for rem value and space.large for pixel value.

[For maintainers] Updating design variables

There are three steps needed to update the set of available designs variables in this repo:

  1. generate a JSON-export of the variable set from Figma
  2. Update the corresponding JSON-file in the src folder
  3. Build the new variables and commit the changes

1. Generate a JSON export

The JSON is exported from Figma using the variabels2css-plugin, download the plugin if you haven't already. Go to the Figma file containing the variables you want to export, eg. Semantic Colors. In you menu bar, select 'Plugins' and choose 'variables2css' – this opens a modal. Under 'choose your collection' choose the variable set you want to export. Under 'type' choose 'JSON', and under 'color' and 'unit' choose 'hex' and 'rem'. Then click 'Generate' and copy the result.

2. Update JSON file

Back in this repo, find the JSON-variables file you want to update, eg. semantic.json, delete its content and paste the generated result you copied in step 1. Then save the file.

3. Build variables

When the JSON-file content is updated, run the script yarn build inside this package or yarn build:packages from root. This will generate new files with updated values in both this package and in all other packages where the component color value has been updated. Once the build is finished, commit all changes and push the commit.

版本与发布记录

@entur/tokens 共发布 110 个版本,首次发布于 2019/09/25;过去 12 个月发布了 23 个版本。

版本发布日期距今
4.3.1latest2026/11/0211 天前
4.3.02026/10/2915 天前
4.2.02026/09/171 个月前
4.1.12026/09/082 个月前
4.1.02026/08/282 个月前
4.0.12026/08/063 个月前

其他发布通道:next → 4.0.0-next.1。

关于 @entur/tokens 的常见问题

@entur/tokens 是什么?

This package contains all design tokens and design variables used throughout the design system. We are currently in a process to migrate over to a new design variable system based on [Figma Variables](https://help.figma.com/hc/en-us/articles/1533965713538

如何安装 @entur/tokens?

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

@entur/tokens 支持 TypeScript 吗?

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

@entur/tokens 支持 ESM 还是 CommonJS?

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

@entur/tokens 可以商用吗?

@entur/tokens 使用 EUPL-1.2 许可。声明的许可为 EUPL-1.2,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

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

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

@entur/tokens 还在维护吗?

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