@krizaka/tailwind

中文文档
3.80.0发布于 2026/11/01Apache-2.0ES Module零依赖构建来源已验证

The Krizaka Tailwind CSS v4 preset: the semantic --kz-* tokens as utilities (bg-surface-1, text-fg-secondary, border-border-default, text-accent, rounded-xl…), illustration-only light/dark variants and the Krizaka easing.

原始使用文档
文档目录6 节
  1. Install
  2. Wiring an app
  3. Utilities by role
  4. The rule
  5. A product theme
  6. License

@krizaka/tailwind

The Krizaka Tailwind CSS v4 preset. It turns the semantic --kz-* tokens of @krizaka/tokens into utilities (bg-surface-1, text-fg-secondary, border-border-default, text-accent, rounded-xl…), gives the illustration-only light: / dark: variants, makes the Krizaka easing the default of every transition, and brings the motion signature of @krizaka/ui.

npm License

The utilities are declared with @theme inline: a class reads its variable at use time, so dark, light and a product theme change the values without recompiling a single class.

Install

npm install -D tailwindcss @krizaka/tailwind @krizaka/tokens @krizaka/ui

tailwindcss (^4.1), @krizaka/tokens and @krizaka/ui are peer dependencies: the app owns their versions, which @krizaka/tokens, @krizaka/ui and @krizaka/tailwind share (one Changesets fixed group).

Wiring an app

Four lines in the app's global stylesheet (a product's web app, app/globals.css), in this order:

@import "tailwindcss";
@import "@krizaka/tailwind";                           /* tokens + utilities + variants + motion */
@import "@krizaka/ui/tailwind.css";                    /* `@source "./dist"`: Tailwind scans the primitives */
@import "@krizaka/myapp-design-system/theme.css";      /* the product's identity: --kz-* overrides + @source of the kit */
@source "../../../packages";                           /* the packages of the product's workspace */

The first two lines are enough to get the whole vocabulary. @krizaka/ui/tailwind.css arrives with the @krizaka/ui 2.0 primitives; until then, leave that line out.

Utilities by role

RoleUtilities (any colour utility: bg-, text-, border-, ring-, from-, fill-…)Token
Surfacessurface-0 page · surface-1 card · surface-2 raised · surface-3 active--kz-surface-*
Mediamedia (background before load) · scrim, scrim-strong (veil on an image) · overlay (dialog backdrop)--kz-media, --kz-scrim*, --kz-overlay
Bordersborder-subtle · border-default · border-strong → border-border-default--kz-border-*
Textfg · fg-secondary · fg-muted · fg-on-media → text-fg-secondary--kz-text-*
Accentaccent · accent-hover · accent-soft · accent-2 (gradients) · on-accent · ring--kz-accent*, --kz-on-accent, --kz-ring
Statussuccess · warning · danger · info (fills, borders, dots, icons — ≥ 3:1)--kz-success …
Status textfg-success · fg-warning · fg-danger · fg-info → text-fg-danger (small text, ≥ 4.5:1 on every surface, both themes)--kz-*-text
Status tintssuccess-soft · warning-soft · danger-soft → bg-danger-soft (the primary and the status text ≥ 4.5:1 on them)--kz-*-soft
Radiusrounded-sm · rounded-md · rounded-lg · rounded-xl · rounded-full; rounded-(--kz-radius-xs), rounded-(--kz-radius-2xl) (not mapped: Tailwind's own xs / 2xl keep their sizes in the products)--kz-radius-*
Shadowshadow-sm · shadow-md · shadow-lg; the signature: shadow-raised · shadow-floating · shadow-overlay (ink-tinted, multi-layer) · shadow-glow · shadow-glow-lg (the brand's light under what acts)--kz-shadow-*, --kz-accent
Edgesinset-shadow-edge (the top edge catches the light) · inset-shadow-edge-fill (on an accent fill) · inset-shadow-well (a field, a track)--kz-edge-*
Materialbg-sheen (the top of a raised surface) · bg-fill-shade (the bottom of a fill) · bg-halo (the brand from the top) · glass (+ bg-glass, border-glass-border)--kz-surface-sheen, --kz-fill-shade, --kz-glass-*
Focusfocus-visible:focus-ring (a crisp ring off the element, in a halo) · focus-ring-inset (on the border)--kz-ring*
Nodenode · node-lit — the core of the marks as a state mark--kz-accent
Fontfont-sans · font-display · font-mono--kz-font-*
Motionease-kz, ease-spring; every transition* defaults to 200 ms on --kz-ease; duration-(--kz-duration-fast) for the micro-interactions (0 under reduced motion)--kz-ease*, --kz-duration-*

The material is BRAND.md §6 of @krizaka/tokens. Merge these classes with twMergeConfig (@krizaka/ui/cn) in your own twMerge, or bg-sheen will be taken for a background colour. The griffe (the 45° cut corner) is [corner-shape:var(--kz-cut-shape)] with rounded-(--kz-cut-size); --kz-cut-shape: round turns it off for an app.

Opacity modifiers work on every colour: bg-surface-1/70, shadow-accent/20.

The preset also sets the Tailwind v3 border rendering (border draws --kz-border-default, not currentColor), the pointer cursor on enabled buttons, and the placeholder colour (--kz-text-muted).

The rule

light: and dark: are for illustrations. A theme is a set of tokens.

A component never switches classes with the theme: bg-zinc-950/70 light:bg-white is bg-surface-1/70, text-zinc-400 light:text-slate-500 is text-fg-secondary, bg-black/60 text-white on an image is bg-scrim text-fg-on-media (identical in both themes). The variants exist only for what no token can express — an illustration or an image that has a light and a dark version — and are refused by lint in the products.

VariantMatches
light:html.light, outside any .theme-dark island
dark::root:not(.light), and anything inside .theme-dark

.theme-dark keeps a player, an editor or a media dark in both themes.

A product theme

A product never redefines a palette: it overrides roles, in its design system's theme.css.

/* @krizaka/myapp-design-system/theme.css — a product identity, expressed as roles */
@source "./dist";

:root, .theme-dark {
  --kz-surface-0: #060709;
  --kz-surface-1: #0c0e14;
  --kz-surface-2: #121520;
  --kz-surface-3: #1a1e2c;
  --kz-border-default: #1f2438;
  --kz-accent:       #8b5cf6;   /* velvet  */
  --kz-accent-hover: #7c3aed;
  --kz-accent-soft:  rgb(139 92 246 / 0.12);
  --kz-accent-2:     #ec4899;   /* sensual — from-accent to-accent-2 gradients become velvet → magenta */
  --kz-ring:         #a78bfa;
  --kz-font-display: Outfit, var(--kz-font-sans);
}
html.light {
  /* Luminous Ivory Cashmere & Rose */
  --kz-surface-0: hsl(210 20% 98%);
  --kz-accent:       #7c3aed;
  --kz-accent-2:     #db2777;
  --kz-accent-soft:  rgb(124 58 237 / 0.08);
}

/* Product tokens: prefixed, never generic */
:root { --myapp-story-ring: linear-gradient(135deg, var(--kz-accent), var(--kz-accent-2)); }

Every utility above follows, without one line in the components: bg-accent is velvet, and so is every ring, tint and rail that mixes the accent. An extra theme (html.theme-cyberpunk { --kz-accent: … }) costs a CSS block, never a component.

License

Apache-2.0 © Krizaka

版本与发布记录

@krizaka/tailwind 共发布 109 个版本,首次发布于 2026/10/10;过去 12 个月发布了 109 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.80.0latest2026/11/011 天前
3.79.02026/10/312 天前
3.78.12026/10/313 天前
3.78.02026/10/313 天前
3.77.02026/10/304 天前
3.76.12026/10/304 天前

其他发布通道:beta → 2.0.0-beta.6。

关于 @krizaka/tailwind 的常见问题

@krizaka/tailwind 是什么?

Krizaka顺风CSS v4预设:语义——kz-*标记作为实用工具(bg-surface-1, text-fg-secondary, border-border-default, text-accent, round -xl…),仅插图的亮/暗变体和Krizaka缓和。

如何安装 @krizaka/tailwind?

在项目目录运行 npm install @krizaka/tailwind,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@krizaka/ui(^3.80.0)、tailwindcss(^4.1)、@krizaka/tokens(^3.80.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@krizaka/tailwind 支持 TypeScript 吗?

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

@krizaka/tailwind 支持 ESM 还是 CommonJS?

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

@krizaka/tailwind 需要什么版本的 Node.js?

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

@krizaka/tailwind 可以商用吗?

@krizaka/tailwind 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@krizaka/tailwind 还在维护吗?

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