@galaxy-ds/tokens

中文文档
3.0.0发布于 2026/09/14TypeScriptESM + CJS零依赖近 30 天下载 2301

@galaxy-ds/tokens package provides css, scss, js, ios and android tokens to unify styles accross all platforms and themes.

原始使用文档
文档目录9 节
  1. Current Use
  2. Figma
  3. Figma Design System
  4. Figma plugins
  5. Use
  6. Output
  7. Migrating to 3.0
  8. Migrating with DEPRECATED_ (no silent surprises)
  9. Other changes

Galaxy Tokens

@galaxy-ds/tokens package provides css, scss, js, ios and android tokens to unify styles accross all platforms and themes.

Current Use

  • @galaxy-ds/tokens will be used within GUI (Bootstrap) providing css variables for desktop/web/mobile theme overrides

Figma

Galaxy uses Figma to bring design and code together turning Figma Styles to usable Tokens that can be used within any project for any platform.

Figma Design System

  • GDS LEAP : Colors, Spacing, Typography

Figma plugins

Use

To add to a project using npm:

# Using npm:
npm install --save @galaxy-ds/tokens

# OR Yarn:
yarn add @galaxy-ds/tokens

CSS

To make use of the css variables, import them into your code like so:

/* Inside css */
@import "@galaxy-ds/tokens/<theme>/<platform>/tokens.css";

JS

Use the package subpath exports — <theme>/<platform> (currently leap/web, leap/desktop, lawconnect/web, lawconnect/desktop). Bundlers get the tree-shakeable ES module, Node/Jest get the CommonJS build, and the bare @galaxy-ds/tokens entry defaults to the LEAP web set:

import * as tokens from "@galaxy-ds/tokens/leap/web";
// or pull only what you need (tree-shakeable):
import { ColorPrimaryMain } from "@galaxy-ds/tokens/leap/web";

Only the curated subpaths are public. The internal dist/... layout is no longer exported, so deep imports like @galaxy-ds/tokens/dist/leap/web/tokens.js no longer resolve under modern (exports-aware) resolution - import from the <theme>/<platform> subpaths instead.

SCSS

To make use of the scss variables, import them into your scss files like so:

@use '@galaxy-ds/tokens/<theme>/<platform>/tokens.scss';

Output

You should see something like this output:

Copying starter files...

desktop
✔︎  build/[BRAND]/desktop/tokens.css
✔︎  build/[BRAND]/desktop/tokens.scss
✔︎  build/[BRAND]/desktop/tokens.js

web
✔︎  build/[BRAND]/web/tokens.css
✔︎  build/[BRAND]/web/tokens.scss
✔︎  build/[BRAND]/web/tokens.js

android
✔︎ build/[BRAND]/android/tokens.colors.xml
✔︎ build/[BRAND]/android/tokens.dimens.xml
✔︎ build/[BRAND]/android/tokens.font_dimens.xml

ios
✔︎ build/[BRAND]/ios/tokens.h
 

Migrating to 3.0

3.0 reorganised the LEAP token set. The platform used to be baked into the token name; now it lives in the output path and has been dropped from the name. 3.0 also revalued the LEAP web typography — these are not pure renames (e.g. Open Sans → Segoe UI Variable, unitless line-heights like 1.25 → pixel values like 40px, and several sizes shifted):

Before (≤ 1.x)After (3.0)
FontWebH1FontWeightFontH1FontWeight
FontWebBody1FontSizeFontBody1FontSize
RadiusWebSmRadiusSm
RadiusWebMdRadiusMd
FontIosSystem / FontAndroidSystemFontPlatformSystem

The rule is mechanical: drop the platform segment (Web / Desktop) that followed Font/Radius.

Migrating with DEPRECATED_ (no silent surprises)

The old names are gone, so usages won't compile after upgrading — that's deliberate. We don't ship silent aliases, because the values changed: an alias that kept the old name but returned the new value would change your UI without any warning.

Instead, the LEAP web and desktop sets re-export every removed name under a DEPRECATED_ prefix, frozen to its 1.x value. So you get a clean, two-step migration:

  1. Keep the old look — find-and-replace the old names to add the prefix (FontWebH1FontSize → DEPRECATED_FontWebH1FontSize). One mechanical pass, the build goes green, and the output is pixel-identical to 1.x.
  2. Adopt the 3.0 look — at your own pace, swap each DEPRECATED_* for its replacement (DEPRECATED_FontWebH1FontSize → FontH1FontSize). grep DEPRECATED_ tells you what's left.

Every DEPRECATED_* constant carries an @deprecated JSDoc pointing at its replacement, and they are all removed in 4.0. The exhaustive old name → frozen value → replacement map lives in deprecated-tokens.json and is the source of truth for the build.

Other changes

  • lawconnect brand is built again (dist/lawconnect/**). Drop any @galaxy-ds/[email protected] alias you were using to keep it alive.
  • TypeScript declarations ship alongside every JS/CJS bundle, so tokens are typed instead of any.
  • Bare @galaxy-ds/tokens imports resolve to the LEAP web set via a root barrel (main/types were previously broken).
  • Contextual.Background.{Light,Dark} restored for LEAP — currently placeholder values mirroring Contextual.Info, pending design sign-off.

版本与发布记录

@galaxy-ds/tokens 共发布 8 个版本,首次发布于 2021/10/29;过去 12 个月发布了 4 个版本。

版本发布日期距今
3.0.0latest2026/09/142 个月前
3.0.0-beta.2beta2026/06/174 个月前
3.0.0-beta.12026/06/055 个月前
3.0.0-beta.02026/04/176 个月前
1.0.32024/08/292 年前
1.0.22024/08/282 年前

关于 @galaxy-ds/tokens 的常见问题

@galaxy-ds/tokens 是什么?

@galaxy-ds/tokens package provides css, scss, js, ios and android tokens to unify styles accross all platforms and themes.

如何安装 @galaxy-ds/tokens?

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

@galaxy-ds/tokens 支持 TypeScript 吗?

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

@galaxy-ds/tokens 支持 ESM 还是 CommonJS?

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

@galaxy-ds/tokens 需要什么版本的 Node.js?

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

@galaxy-ds/tokens 可以商用吗?

@galaxy-ds/tokens 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@galaxy-ds/tokens 的下载量有多少?

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

@galaxy-ds/tokens 还在维护吗?

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