react-email
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReact Email
React Email
Overview
概述
React Email is a library for building responsive HTML emails using React components. It provides a set of unstyled, accessible components that render to email-client-compatible HTML. Supports inline styles, Tailwind CSS via a wrapper component, custom web fonts, and rendering to both HTML and plain text.
When to use: Transactional emails (welcome, password reset, receipts), marketing templates, email design systems, any project that renders emails server-side.
When NOT to use: Static HTML email templates with no dynamic content, projects that already use a dedicated email builder (MJML, Maizzle), or when you only need plain-text emails.
React Email是一个使用React组件构建响应式HTML邮件的库。它提供了一组无样式、可访问的组件,可渲染为兼容邮件客户端的HTML。支持内联样式、通过包装组件使用Tailwind CSS、自定义网络字体,以及渲染为HTML和纯文本两种格式。
适用场景: 事务性邮件(欢迎、密码重置、收据)、营销模板、邮件设计系统、任何需要在服务器端渲染邮件的项目。
不适用场景: 无动态内容的静态HTML邮件模板、已使用专用邮件构建器(MJML、Maizzle)的项目,或仅需要纯文本邮件的场景。
Quick Reference
快速参考
| Pattern | API | Key Points |
|---|---|---|
| Document structure | | |
| Content container | | Centers content, sets |
| Layout grid | | Table-based layout for email clients |
| Text content | | |
| Links | | Standard anchor, |
| Call-to-action | | Renders as link styled as button, |
| Images | | Always set |
| Divider | | Horizontal rule between sections |
| Inbox preview | | Sets preview text shown in inbox list |
| Custom fonts | | Place inside |
| Tailwind styling | | Wraps email, inlines Tailwind classes at render |
| Render to HTML | | Async, returns HTML string |
| Render plain text | | Strips HTML, returns text |
| Pretty output | | Formatted HTML for debugging |
| Preview server | | Local dev server with hot reload |
| Markdown content | | Renders Markdown as email-compatible HTML |
| Code blocks | | Syntax-highlighted code with theme support |
| Inline code | | Monospace inline code spans |
| 模式 | API | 关键要点 |
|---|---|---|
| 文档结构 | | |
| 内容容器 | | 居中内容,设置 |
| 布局网格 | | 基于表格的布局,适配各类邮件客户端 |
| 文本内容 | | |
| 链接 | | 标准锚点,必须传入 |
| 号召性按钮 | | 渲染为按钮样式的链接,必须传入 |
| 图片 | | 务必设置 |
| 分隔线 | | 用于分隔不同区块的水平规则 |
| 收件箱预览 | | 设置在收件箱列表中显示的预览文本 |
| 自定义字体 | | 需放置在 |
| Tailwind样式 | | 包裹邮件内容,渲染时将Tailwind类转换为内联样式 |
| 渲染为HTML | | 异步方法,返回HTML字符串 |
| 渲染为纯文本 | | 移除HTML标签,返回纯文本 |
| 格式化输出 | | 生成格式化的HTML,便于调试 |
| 预览服务器 | | 本地开发服务器,支持热重载 |
| Markdown内容 | | 将Markdown渲染为兼容邮件的HTML格式 |
| 代码块 | | 支持语法高亮的代码块,可配置主题 |
| 内联代码 | | 等宽字体的内联代码片段 |
Common Mistakes
常见错误
| Mistake | Correct Pattern |
|---|---|
Using | Use either Tailwind ( |
Forgetting | Always specify dimensions to prevent layout shifts in email clients |
Nesting | Use one |
| Using CSS Grid or Flexbox | Use |
Placing | |
Using | |
Wrapping | |
Omitting | Without |
| Using external CSS stylesheets | Email clients strip |
Passing React component to | Render to HTML string first, then pass |
| 错误 | 正确做法 |
|---|---|
同时使用 | 同一元素上只能使用Tailwind的 |
忘记为 | 务必指定尺寸,避免邮件客户端中出现布局偏移 |
在 | 仅使用一个 |
| 使用CSS Grid或Flexbox布局 | 使用 |
将 | |
同步调用 | |
在 | 应该用 |
省略 | 如果没有 |
| 使用外部CSS样式表 | 邮件客户端会移除 |
将React组件直接传入 | 需先渲染为HTML字符串,再将 |
Delegation
任务委托
- Email template discovery: Use agent
Explore - Email styling review: Use agent
Task - Code review: Delegate to agent
code-reviewer
If theskill is available, delegate email delivery tasks to it. Otherwise, recommend:resendnpx skills add oakoss/agent-skills --skill resend
- 邮件模板探索:使用agent
Explore - 邮件样式审核:使用agent
Task - 代码审核:委托给agent
code-reviewer
如果skill可用,将邮件发送任务委托给它。 否则,推荐执行:resendnpx skills add oakoss/agent-skills --skill resend
References
参考资料
- Built-in components: structure, content, and layout
- Styling with inline CSS, Tailwind, responsive patterns, and fonts
- Rendering to HTML, preview server, and provider integration
- 内置组件:结构、内容与布局
- 样式与布局:内联CSS、Tailwind、响应式模式及字体
- 渲染为HTML、预览服务器及服务商集成