@lovince/themes

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

Light and dark themes for Lovince UI — semantic colour roles over @lovince/tokens, emitted as CSS custom properties and a Tailwind v4 theme.

原始使用文档
文档目录5 节
  1. Use it
  2. Switching themes
  3. Guarantees
  4. Editing
  5. License

@lovince/themes

Light and dark themes for Lovince UI. A theme maps the primitives in @lovince/tokens onto semantic roles (surface, foreground, line, accent, danger…), so components ask for what a colour is for, never which colour it is.

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

bun add @lovince/themes @lovince/tokens

Use it

Plain CSS:

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

.card {
  background: var(--lovince-color-surface-raised);
  color: var(--lovince-color-fg);
  border: 1px solid var(--lovince-color-line);
  box-shadow: var(--lovince-shadow-md);
}

Tailwind v4. This brings in both sheets, a Tailwind theme, base styles, enter/exit animations, and a dark: variant that follows [data-theme]:

@import 'tailwindcss';
@import '@lovince/themes/tailwind.css';

Utilities use the shadcn vocabulary (bg-primary, text-muted-foreground, border-input, ring-ring) mapped onto Lovince roles, so shadcn-style components are themed with no edits. Type is by role: text-title-md, text-body-sm.

TypeScript:

import { themes, SEMANTIC_COLORS } from '@lovince/themes'

Switching themes

Light is the default. prefers-color-scheme: dark switches automatically unless data-theme="light" is set. Set data-theme="dark" on <html>, or on any subtree, to force it. Derived values (hover tints, shadows, focus ring) are re-resolved inside each [data-theme] subtree, so a dark panel on a light page is fully dark.

Guarantees

  • Every role is defined by every theme.
  • WCAG AA contrast is tested for every text/surface pairing in both themes: 4.5:1 for text, 3:1 for focus rings and borders.
  • danger is a fill and danger-ink is for text and borders, because no single red passes AA in both roles on dark surfaces.
  • The theme sheet holds no raw colours, only references to tokens.

Editing

The source is src/. css/themes.css and css/tailwind.css are generated: run bun run generate from the repository root.

License

MIT

版本与发布记录

@lovince/themes 共发布 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/themes 的常见问题

@lovince/themes 是什么?

Lovince UI的浅色和深色主题- @lovince/令牌上的语义颜色角色,作为CSS自定义属性和Tailwind v4主题发出。

如何安装 @lovince/themes?

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

@lovince/themes 支持 TypeScript 吗?

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

@lovince/themes 支持 ESM 还是 CommonJS?

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

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

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

@lovince/themes 可以商用吗?

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

@lovince/themes 还在维护吗?

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