Tailwind 转换为内联样式工具
将 Tailwind CSS 类转换为适用于邮件模板的内联样式。
在线试用
安装
npm install tailwind-to-inline使用方法
#### 从文件路径转换
import { makeStylesInline } from 'tailwind-to-inline';const htmlTemplate = await makeStylesInline('templates/welcome-email.html', {
name: 'John',
cta_text: 'Complete Profile'
});
参数:
templatePath— 模板文件的路径。placeholderValues(可选) — 一个键值对对象,用于替换模板中的动态内容。
import { makeStylesInlineFromString } from 'tailwind-to-inline';const html = Hello, {{name}};
const htmlTemplate = await makeStylesInlineFromString(html, {
name: 'John',
});
参数:
templateString— 包含 Tailwind CSS 类的原始 HTML 字符串。data(可选) — 用于替换模板中动态内容的键值对对象。
示例
#### 原始模板welcome-email.html:
Welcome, {{name}}
#### 转换结果:
Welcome, John
贡献
欢迎贡献、提交问题和功能请求!
贡献者
许可证
本项目采用 MIT 许可证。
--- Tranlated By Open Ai Tx | Last indexed: 2026-06-09 ---


