@lovince/tokens

中文文档
0.3.0发布于 2026/11/02MITTypeScriptES Module零依赖

Design tokens for Lovince UI — palette, spacing, type, motion and layering scales as typed constants and CSS custom properties. No dependencies.

原始使用文档
文档目录5 节
  1. Three tiers
  2. Use it
  3. Decisions
  4. Editing
  5. License

@lovince/tokens

The raw design values of Lovince UI: colour primitives, space, radius, type, motion, blur and layering. They are decided once here, and every other package consumes them. No dependencies.

Status: 0.3.0, experimental. Token names may change before 1.0.

bun add @lovince/tokens

Tokens carry no meaning. --lovince-blue-600 is a colour, not "the accent". Meaning comes from @lovince/themes, which maps these primitives onto semantic roles. Most apps want both.

Three tiers

TierPackageExampleWho references it
Primitive@lovince/tokens--lovince-blue-600, --lovince-space-4, --lovince-duration-enterThemes, and components for non-colour scales
Semantic@lovince/themes--lovince-color-surface, --lovince-color-accentComponents
Componenteach package--journey-primaryConsumers overriding one component

Rebranding edits a primitive. Dark mode edits semantics. Neither touches a component.

Use it

@import '@lovince/tokens/tokens.css';

.panel { padding: var(--lovince-space-4); border-radius: var(--lovince-radius-lg); }
import { duration, ease, space, contrastRatio } from '@lovince/tokens'

gsap.to(el, { duration: duration.enter, ease: ease.out.gsap })

Every selector is wrapped in :where(), so a plain :root { --lovince-… } override always wins, whatever the import order.

Decisions

  • Palette: slate neutrals with blue 600 (#2563eb) as the brand accent, plus red, green and amber for status, all in OKLCH.
  • Space is a 4px scale. Durations sit on a 40ms step: press 120 · fast 160 · micro 200 · state 280 · morph 360 · enter 440 · overlay 560 · travel 720. Each easing ships with its GSAP equivalent, so CSS and JS motion never disagree.
  • Type is addressed by role (title-md, body-sm…), never by size. Fonts default to system stacks; set --lovince-font-sans to brand a product.
  • Weight floor: nothing is set lighter than 500.

Editing

The source is src/. css/tokens.css is generated: run bun run generate from the repository root, never edit it by hand. A test fails if the committed file drifts from the source.

License

MIT

版本与发布记录

@lovince/tokens 共发布 4 个版本,首次发布于 2026/10/16;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.3.0latest2026/11/021 天前
0.2.02026/11/021 天前
0.1.02026/10/1618 天前
0.0.0-stage2026/10/1618 天前

关于 @lovince/tokens 的常见问题

@lovince/tokens 是什么?

为Lovince UI设计令牌-调色板,间距,类型,运动和分层尺度作为类型常量和CSS自定义属性。没有依赖关系。

如何安装 @lovince/tokens?

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

@lovince/tokens 支持 TypeScript 吗?

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

@lovince/tokens 支持 ESM 还是 CommonJS?

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

@lovince/tokens 需要什么版本的 Node.js?

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

@lovince/tokens 可以商用吗?

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

@lovince/tokens 还在维护吗?

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