@_tw/themejson

中文文档
0.2.1发布于 2025/01/21MITCommonJS零依赖近 30 天下载 3136

A Tailwind CSS plugin that adds colors and widths from a WordPress theme’s theme.json file to a Tailwind project’s configuration.

原始使用文档

_tw × theme.json

A Tailwind CSS plugin created for _tw that automatically pulls colors and widths from a WordPress theme’s theme.json file, initiated as follows:

// tailwind.config.js
plugins: [
    require('@_tw/themejson'),
]

By default, the theme.json file will be loaded from ./theme/theme.json, relative to the current working directory. (The default path corresponds with that of _tw.) You can override this location by passing a new path as a string:

// tailwind.config.js
plugins: [
    require('@_tw/themejson')('path/to/theme.json'),
]

You can also parse theme.json yourself and pass in the corresponding object:

// tailwind.config.js
plugins: [
    require('@_tw/themejson')(require('path/to/theme.json')),
]

You may need to manage caching should you choose to use require to parse the JSON file.

After initiation, the plugin will extract the base color palette (settings.color.palette) as well as values for contentSize and wideSize.

If one or more of your color palette’s slug values matches a slug in Tailwind’s default color palette, those colors from the default palette—including all shades—will be overridden by the color value from your theme.json file.

版本与发布记录

@_tw/themejson 共发布 5 个版本,首次发布于 2021/09/09;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.1latest2025/01/211.8 年前
0.2.02023/11/172 年前
0.1.22021/09/095 年前
0.1.12021/09/095 年前
0.1.02021/09/085 年前

关于 @_tw/themejson 的常见问题

@_tw/themejson 是什么?

A Tailwind CSS plugin that adds colors and widths from a WordPress theme’s theme.json file to a Tailwind project’s configuration.

如何安装 @_tw/themejson?

在项目目录运行 npm install @_tw/themejson,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:tailwindcss(>=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@_tw/themejson 支持 TypeScript 吗?

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

@_tw/themejson 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@_tw/themejson 可以商用吗?

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

@_tw/themejson 的下载量有多少?

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

@_tw/themejson 还在维护吗?

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