@eightshift/frontend-libs-tailwind

中文文档
3.5.1发布于 2026/11/11MIT近 30 天下载 2313

A framework for creating modern Gutenberg themes with styling provided by Tailwind CSS.

原始使用文档
文档目录5 节
  1. Documentation
  2. Tailwind class linting
  3. Who do I talk to?
  4. Maintainers
  5. License

image

GitHub tag GitHub stars license

Eightshift Frontend Libs Tailwind

This library is meant to bring you the modern front-end development tools to the Eightshift Boilerplate or Eightshift Boilerplate Plugin, but you can use it on any WordPress project.

Documentation

For the full documentation please check this link.

Tailwind class linting

Two tools check classes against your project's own Tailwind entry: oxlint for JS, and tw-sweep for block manifests and PHP. Both read one ignore list.

  1. Add oxlint to your project's devDependencies. Isolated installs (pnpm, bun --linker isolated) do not expose this package's binaries.

  2. Create oxlint.config.ts:

    import { defineConfig } from 'oxlint';
    import { createOxlintConfig } from '@eightshift/frontend-libs-tailwind/linters/oxlint.config.mjs';
    
    export default defineConfig(createOxlintConfig({ entryPoint: 'tailwind.css' }));
    
  3. Create tw-ignore.json for classes that are not Tailwind utilities (JS hooks, BEM selectors, other design-system prefixes). It is a JSON array of regex strings; an invalid pattern stops both tools:

    ["^es:", "^js-", "^my-block__"]
    
  4. Wire the scripts. lint-staged does not run commands through a shell, so use an array instead of &&:

    "scripts": {
     "lintJs:oxlint": "oxlint",
     "lintTw": "tw-sweep",
     "test": "bun run lintJs && bun run lintJs:oxlint && bun run lintTw"
    },
    "lint-staged": {
     "*.js": ["bun lintJs", "bun lintJs:oxlint"],
     "src/Blocks/**/manifest.json": "tw-sweep",
     "src/**/*.php": "tw-sweep"
    }
    

tw-sweep reports unknown and non-canonical classes; tw-sweep --write rewrites the non-canonical ones. In PHP it reads static class="…" attributes and the string arguments of tailwindClasses, getTwPart, getTwClasses, clsx and classnames. For class maps that no helper wraps, such as selectors returned from a filter, mark the code:

// tw-sweep-classes-start.
$selectors['field']['parts']['label'] = ['flex items-center text-body-sm'];
// tw-sweep-classes-end.

Every string literal between the markers that is not an array key is checked. Run tw-sweep --help for all flags.

Who do I talk to?

If you have any questions or problems, please open an issue on GitHub and we will do our best to give you a timely answer.

Maintainers

Eightshift Frontend Libs Tailwind is maintained and sponsored by Eightshift and Infinum.

License

Eightshift Frontend Libs Tailwind Eightshift and Infinum. This is free software, and may be redistributed under the terms specified in the LICENSE file.

版本与发布记录

@eightshift/frontend-libs-tailwind 共发布 44 个版本,首次发布于 2024/07/01;过去 12 个月发布了 15 个版本。

版本发布日期距今
3.5.1latest2026/11/112 天前
4.0.0-beta.4beta2026/11/113 天前
4.0.0-beta.32026/11/094 天前
4.0.0-beta.22026/11/067 天前
4.0.0-beta.12026/11/058 天前
3.5.02026/10/1925 天前

关于 @eightshift/frontend-libs-tailwind 的常见问题

@eightshift/frontend-libs-tailwind 是什么?

A framework for creating modern Gutenberg themes with styling provided by Tailwind CSS.

如何安装 @eightshift/frontend-libs-tailwind?

在项目目录运行 npm install @eightshift/frontend-libs-tailwind,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@eightshift/ui-components(^8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 tw-sweep,可以用 npx tw-sweep 直接运行。

@eightshift/frontend-libs-tailwind 支持 TypeScript 吗?

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

@eightshift/frontend-libs-tailwind 可以商用吗?

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

@eightshift/frontend-libs-tailwind 的下载量有多少?

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

@eightshift/frontend-libs-tailwind 还在维护吗?

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