@gener8v/tailwind-preset

中文文档
0.64.0发布于 2026/11/10MITES Module零依赖近 30 天下载 4667

Tailwind v4 @theme over the GENER8V tokens, so utilities and the component layer share one source.

原始使用文档
文档目录4 节
  1. The word "contents"
  2. When to use a utility and when not to
  3. Why this exists at all
  4. What is generated

@gener8v/tailwind-preset

Tailwind v4 @theme generated from the same tokens as the stylesheet, so utilities and the component layer can never disagree.

npm i @gener8v/tailwind-preset     # public on npm, MIT
@import "tailwindcss";
@import "@gener8v/tailwind-preset/theme.css";

Then bg-action, p-6, rounded-md, text-2xl resolve to the system's values rather than Tailwind's defaults.

The word "contents"

Tailwind v4 generates display: contents for any source file that contains the word "contents" (prose, a comment, a variable). That utility strips the box from the system's Contents component. theme.css therefore carries @source not inline("contents");, so the utility is never generated and you need no line of your own. If you do want Tailwind's contents utility, add @source inline("contents"); after the preset import. The component also keeps its box with nav.contents, .contents-nav { display: block }.

When to use a utility and when not to

Prefer the semantic classes for anything the system already names. .btn, .card, .tag, .panel, .field — these carry states, focus treatment and accessibility styling that a stack of utilities will not reproduce, and rebuilding a button out of bg-action px-4 py-2 rounded-md gets you something that looks like a button and behaves like a div.

Utilities are for layout the system does not cover: a one-off grid, a gap, a max-width on a page section. That is the line.

Why this exists at all

The system's own components use semantic classes, not utilities. This preset is here so a consuming repo already standardised on Tailwind can lay out pages with familiar utilities without hard-coding a single value — and so those utilities resolve to the same numbers the components use. It is a bridge, not the primary interface.

What is generated

Colours (every ramp step and role), spacing, the type scale, radii, shadows and motion — the same values as @gener8v/tokens. theme.css is generated by pnpm build:tokens; never hand-edit it, and CI will fail if you do.

版本与发布记录

@gener8v/tailwind-preset 共发布 80 个版本,首次发布于 2026/08/24;过去 12 个月发布了 80 个版本。

版本发布日期距今
0.64.0latest2026/11/106 天前
0.63.02026/11/0511 天前
0.62.02026/11/0511 天前
0.61.02026/11/0411 天前
0.60.02026/11/0412 天前
0.59.12026/11/0312 天前

关于 @gener8v/tailwind-preset 的常见问题

@gener8v/tailwind-preset 是什么?

Tailwind v4 @theme over the GENER8V tokens, so utilities and the component layer share one source.

如何安装 @gener8v/tailwind-preset?

在项目目录运行 npm install @gener8v/tailwind-preset,或使用 pnpm add / yarn add / bun add。

@gener8v/tailwind-preset 支持 TypeScript 吗?

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

@gener8v/tailwind-preset 支持 ESM 还是 CommonJS?

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

@gener8v/tailwind-preset 可以商用吗?

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

@gener8v/tailwind-preset 的下载量有多少?

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

@gener8v/tailwind-preset 还在维护吗?

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