@flipdish/ui-tokens

中文文档
0.6.0发布于 2026/10/21ES Module零依赖近 30 天下载 2061

Flipdish Design System tokens — a single Tailwind CSS v4 @theme stylesheet consumed by web (Tailwind) and React Native (NativeWind).

原始使用文档
文档目录8 节
  1. Installation
  2. Usage
  3. Web (Tailwind v4)
  4. React Native (NativeWind v5)
  5. Semantic tokens
  6. Theme switching
  7. Changelog
  8. Contributing

@flipdish/ui-tokens

Design tokens for the Flipdish Design System — brand colours, type scale, spacing, and shadows — shipped as a single Tailwind CSS v4 @theme stylesheet that both web (Tailwind) and React Native (NativeWind v5) consume.

Internal design system, published publicly. These tokens encode Flipdish's brand. They're on the public npm registry so they can be shared across Flipdish micro-frontends and apps, not as a general-purpose token set.

Part of the Flipdish Design System:

PackagePurpose
@flipdish/ui-tokensDesign tokens (this package)
@flipdish/ui-iconsIcon set
@flipdish/ui-libraryComponents
@flipdish/ui-connectedAPI-connected components

Installation

pnpm add @flipdish/ui-tokens

No runtime dependencies and no peer dependencies — the package ships one CSS file.

Usage

Web and React Native import the same file. The @theme block populates Tailwind's design system with the token vocabulary, so semantic utilities like bg-primary, text-secondary, and border-primary resolve via CSS custom properties.

Web (Tailwind v4)

@import the CSS from your Tailwind entry stylesheet:

@import "@flipdish/ui-tokens/css" layer(theme); /* tokens + [data-theme="dark"] */

React Native (NativeWind v5)

Add the same import to the global.css NativeWind compiles. NativeWind v5's react-native-css reads Tailwind v4 @theme blocks directly, so no JS theme object or tailwind.config.js preset is needed. See the React Native installation guide for the full global.css shape and the lightningcss pin it requires.

/* global.css, alongside the other imports from the installation guide */
@import "@flipdish/ui-tokens/css" layer(theme);

The Flipdish brand ramp is authored in hex so both Tailwind and react-native-css parse it identically.

Semantic tokens

Tokens are layered: theme-invariant primitives (raw colour ramps, scales) and a semantic mapping (--color-bg-*, --color-fg-*, --color-text-*, --color-border-*, --color-focus-ring) that follows the Untitled UI v8 vocabulary, so Untitled UI components render on-brand out of the box.

Always consume the semantic layer — it's what stays theme-aware:

// ✓ Correct — semantic token, theme-aware
<div className="bg-primary text-secondary border-primary" />

// ✗ Wrong — primitive token, breaks theme switching
<div className="bg-neutral-50 text-neutral-900" />

// ✗ Wrong — raw CSS variable reference
<div style={{ background: "var(--color-bg-primary)" }} />

The same suffix means different things per property: bg-primary is the page background, while text-primary is the near-black body text.

Theme switching

Light is the default. On web, dark mode activates declaratively via a [data-theme="dark"] attribute on the mount node (or any ancestor) — no JavaScript runtime theme-switching code required:

<!-- Light (default) -->
<div id="app">…</div>

<!-- Dark -->
<div id="app" data-theme="dark">…</div>

On React Native there is no DOM attribute to cascade from, so the [data-theme="dark"] block does not apply and semantic tokens keep their light values in both device schemes. NativeWind's dark: variants still follow the device colour scheme.

Changelog

See CHANGELOG.md for release history.

Contributing

This package lives in the flipdish-design-system monorepo. Contributor documentation — how to change a token, the primitive/semantic structure, and what the build-time lint checks — lives alongside the source there.

版本与发布记录

@flipdish/ui-tokens 共发布 13 个版本,首次发布于 2026/06/22;过去 12 个月发布了 13 个版本。

版本发布日期距今
0.6.0latest2026/10/2126 天前
0.5.12026/10/131 个月前
0.5.02026/10/071 个月前
0.4.02026/09/181 个月前
0.3.62026/09/152 个月前
0.3.52026/08/073 个月前

关于 @flipdish/ui-tokens 的常见问题

@flipdish/ui-tokens 是什么?

Flipdish Design System tokens — a single Tailwind CSS v4 @theme stylesheet consumed by web (Tailwind) and React Native (NativeWind).

如何安装 @flipdish/ui-tokens?

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

@flipdish/ui-tokens 支持 TypeScript 吗?

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

@flipdish/ui-tokens 支持 ESM 还是 CommonJS?

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

@flipdish/ui-tokens 可以商用吗?

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

@flipdish/ui-tokens 的下载量有多少?

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

@flipdish/ui-tokens 还在维护吗?

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