@darkalpha/nova-tokens

中文文档
0.9.0发布于 2026/11/14MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2109

Design tokens, color engine and theme definitions for the Nova UI design system. Framework-agnostic.

原始使用文档
文档目录3 节
  1. Layers
  2. Files
  3. Figma variables

@darkalpha/nova-tokens

Design tokens and the color engine behind Nova UI. Framework-agnostic, zero dependencies.

import { auditContrast, generateScale, getResolvedTheme, themeCss } from "@darkalpha/nova-tokens";

generateScale("#6d4aff"); // { 50: "#f6f7ff", …, 600: "#6d4aff", …, 975: "#150644" }

const theme = getResolvedTheme("vibrant", { brand: { primary: "#e11d48" } });
theme.light["primary-solid"]; // "#e11d48" (kept: white text on it passes 4.5:1)
auditContrast(theme).filter((c) => !c.pass); // []

themeCss(theme, ":root"); // CSS custom properties using light-dark()

Layers

  • Primitives (primitives): 20 OKLCH-generated 12-step color scales plus spacing, radius, type, motion, z-index, breakpoints, containers and density. Regenerate colors with pnpm generate:primitives.
  • Semantic (SEMANTIC_COLOR_NAMES): role-based colors — surfaces, text, focus, chart colors, and nine roles for each of eight intents. resolveTheme maps them to primitives per mode and fixes contrast.
  • Component tokens (staticVariables()): narrow knobs such as --nv-button-radius and --nv-card-padding that default to global tokens.

Files

  • @darkalpha/nova-tokens/css/tokens.css: static tokens plus the default theme on :root
  • @darkalpha/nova-tokens/css/themes.css: every preset scoped to [data-nv-theme]
  • @darkalpha/nova-tokens/css/tailwind.css: Tailwind v4 @theme inline mapping
  • @darkalpha/nova-tokens/tokens.json: resolved values for design tools
  • @darkalpha/nova-tokens/tokens.dtcg.json and dtcg/*.json: W3C DTCG tokens (Tokens Studio, Style Dictionary)
  • @darkalpha/nova-tokens/figma/<theme>.json: Figma variables for one theme, as a REST API request body

Figma variables

figmaVariables(themes) turns tokens into Figma variables: a Nova primitives collection (palette, radius, font sizes, weights, line heights, opacity, font families) and a Nova theme collection with a Light and a Dark mode per theme. A semantic color that is exactly a palette step becomes an alias of that palette variable, so the link survives in Figma.

To push them into a file (the Variables REST API needs a Figma Enterprise plan and a token with the file_variables:read and file_variables:write scopes):

pnpm --filter @darkalpha/nova-tokens build
FIGMA_TOKEN=… FIGMA_FILE_KEY=… pnpm --filter @darkalpha/nova-tokens figma:sync --themes vibrant,ocean

Re-running updates the same variables by collection and name instead of duplicating them. --dry-run writes the request body to figma-variables.json without calling Figma. On other plans, import the DTCG files with Tokens Studio.

版本与发布记录

@darkalpha/nova-tokens 共发布 13 个版本,首次发布于 2026/11/04;过去 12 个月发布了 13 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.0latest2026/11/14今天
0.8.02026/11/104 天前
0.7.02026/11/104 天前
0.6.02026/11/095 天前
0.5.12026/11/095 天前
0.5.02026/11/086 天前

关于 @darkalpha/nova-tokens 的常见问题

@darkalpha/nova-tokens 是什么?

Design tokens, color engine and theme definitions for the Nova UI design system. Framework-agnostic.

如何安装 @darkalpha/nova-tokens?

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

@darkalpha/nova-tokens 支持 TypeScript 吗?

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

@darkalpha/nova-tokens 支持 ESM 还是 CommonJS?

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

@darkalpha/nova-tokens 可以商用吗?

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

@darkalpha/nova-tokens 的下载量有多少?

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

@darkalpha/nova-tokens 还在维护吗?

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