@aphrody/m3-tailwind

中文文档
1.4.7发布于 2026/10/23Apache-2.0TypeScriptES Module近 30 天下载 4047

Tailwind v4 CSS-first preset for Material 3: generates @theme (colour roles, shape, typescale, elevation, easing) from @aphrody/m3-tokens.

原始使用文档

@aphrody/m3-tailwind

Tailwind v4 CSS-first preset for Material 3: one @import, no JS plugin, no config file.

bun add @aphrody/m3-tailwind @aphrody/m3-tokens tailwindcss
@import "tailwindcss";
@import "@aphrody/m3-tokens/m3-tokens.css";
@import "@aphrody/m3-tokens/expressive.css";
@import "@aphrody/m3-tailwind/preset.css";

License: Apache-2.0 (LICENSE). Install guide: docs/material/m3/INSTALL.md.

preset.css is generated from @aphrody/m3-tokens (roles, corner scale, type, breakpoints, springs and directional shapes from the TypeScript tables; durations, easings, elevation and state layers from m3-tokens.css).

Colour values are set at runtime (applyDynamicColor, <m3-theme>, M3Html in @aphrody/m3-next).

With Bun, @aphrody/bun-plugin-tailwind adds these imports and a seeded colour scheme on its own: tailwind({ theme: "m3" }) (or { theme: { seed: "#0b57d0" } }), and the same option on its PostCSS plugin.

What it adds

FamilyTheme keys (@theme inline)Utilities and variants
Colour (all 49 roles)--color-*bg-primary, text-on-surface, border-outline-variant, hover:bg-on-surface/8
Shape--radius-*, --shape-*rounded-large, shape-extra-large-top, shape-large-start (RTL-aware)
Type--text-* (15 base + 15 emphasized, with line height, tracking, weight), --font-*text-body-large, text-title-small-emphasized, typescale-label-large (also sets the family), font-brand
Elevation--shadow-elevation-0..5shadow-elevation-2
Motion--ease-*, --transition-duration-*, spring linear() easings and settle timesease-emphasized, duration-medium2, ease-spring-expressive-fast-spatial, motion-default-effects (easing and duration in one class)
Statestate-layer, state-layer-primary (hover, focus, pressed, dragged; honours Base UI data-highlighted, data-pressed, data-disabled)
Adaptive--breakpoint-*compact:, medium:, expanded:, large:, extra-large:, h-compact:, h-medium:, h-expanded:
Schemedark: follows .dark, or the OS unless .light forces light
Base UI statem3-open:, m3-on:, m3-highlighted:, m3-disabled:, m3-invalid:, m3-enter:, m3-exit:, m3-vertical:, m3-horizontal:

@theme inline means a variable is emitted only when a utility uses it, so the preset costs bytes in proportion to what an app writes (see docs/reports/M3-NEXT-BUNDLE.md). themeCss({ keepUnused: true }) emits @theme static.

Springs: CSS has no spring easing and a cubic-bezier cannot overshoot, so each spring token (damping ratio, stiffness) is sampled into a 33-stop linear() with its settle time (src/spring.ts); the Expressive spatial springs keep their bounce.

bun run generate rewrites preset.css; the tests check it is up to date, that every token the preset reads exists in the token sheets, and compile one utility per family with @tailwindcss/node from the root catalog. Pinned upstream sources live in vendor/tailwindcss; local leaf, Cargo/NAPI and artifact integration remains unqualified. The consumer currently uses installed catalog packages, not that source tree.

bun test test/, bun run typecheck.

版本与发布记录

@aphrody/m3-tailwind 共发布 7 个版本,首次发布于 2026/10/05;过去 12 个月发布了 7 个版本。

版本发布日期距今
1.4.7latest2026/10/2315 天前
1.4.42026/10/1820 天前
3.3.112026/10/1028 天前
3.3.92026/10/1029 天前
3.3.82026/10/0929 天前
3.3.72026/10/071 个月前

关于 @aphrody/m3-tailwind 的常见问题

@aphrody/m3-tailwind 是什么?

Tailwind v4 CSS-first preset for Material 3: generates @theme (colour roles, shape, typescale, elevation, easing) from @aphrody/m3-tokens.

如何安装 @aphrody/m3-tailwind?

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

@aphrody/m3-tailwind 支持 TypeScript 吗?

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

@aphrody/m3-tailwind 支持 ESM 还是 CommonJS?

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

@aphrody/m3-tailwind 可以商用吗?

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

@aphrody/m3-tailwind 的下载量有多少?

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

@aphrody/m3-tailwind 还在维护吗?

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