A utility for writing responsive email templates with react-email
npm install responsive-react-emailresponsive-react-email is a utility for writing responsive email templates with react-email.
This tool takes on an opinionated approach to creating responsive email templates using best practices that improve support across majority of email clients.
View Demo on CodeSandbox
- Installation
- Components
- Single-column layout component
- Dual-column layout component
- Triple-column layout component
- Supported email clients
- Contributing
- Bugs and Feature requests
- Author
- License
Add responsive-react-email to your react-email project.
#### With yarn
``sh`
yarn add responsive-react-email
#### With npm
`sh`
npm install responsive-react-email
a react-email component that preserves your content layout as a single column on all screen sizes in the email client.
Example
`
import { SingleColumn } from "responsive-react-email";
{/ OR /}
import { SingleColumn } from "responsive-react-email/single-column"; // for tree-shakeability;
export const DemoTemplate = () => {
return(
{/ OR /}
{/ Content goes here /}
export default DemoTemplate
`
#### children field
- Type: string
- Description: Contains the content that will be rendered in the single column layout of the email template.
#### styles field
- Type: React.CSSProperties
- Description: Provide custom styles for the wrapper component
#### pX field
- Type: number
- Description: Numerical value for padding-left and padding-right.
#### pY field
- Type: number
- Description: Numerical value for padding-top and padding-bottom.
a react-email component that displays your content in a two-column layout on big screens (tablet and desktop) and collapses to a single column on smaller screen sizes.
Example
`
import { DualColumn } from "responsive-react-email";
{/ OR /}
import { DualColumn } from "responsive-react-email/dual-column"; // for tree-shakeability
export const DemoTemplate = () => {
return(
export default DemoTemplate
`
#### columnOneContent field
- Type: string
- Description: Contains the content that will be rendered in the first column of the dual-column layout of the email template.
#### columnOneStyles field
- Type: string
- Description: Provide custom styles for the first column of the dual-column layout of the email template.
#### columnTwoContent field
- Type: string
- Description: Contains the content that will be rendered in the second column of the dual-column layout of the email template.
#### columnTwoStyles field
- Type: string
- Description: Provide custom styles for the second column of the dual-column layout of the email template.
#### styles field
- Type: React.CSSProperties
- Description: Provide custom styles for the wrapper component
#### pX field
- Type: number
- Description: Numerical value for padding-left and padding-right.
#### pY field
- Type: number
- Description: Numerical value for padding-top and padding-bottom.
a react-email component that displays your content in a three-column layout on big screens and collapses in a sort of flex-wrap: wrap manner till it gets to a single column on smaller screen sizes.
Example
`
import { TripleColumn } from "responsive-react-email";
{/ OR /}
import { TripleColumn } from "responsive-react-email/triple-column"; // for tree-shakeability
export const DemoTemplate = () => {
return(
export default DemoTemplate
`
#### columnOneContent field
- Type: string
- Description: Contains the content that will be rendered in the first column of the triple-column layout of the email template.
#### columnOneStyles field
- Type: string
- Description: Provide custom styles for the first column of the triple-column layout of the email template.
#### columnTwoContent field
- Type: string
- Description: Contains the content that will be rendered in the second column of the triple-column layout of the email template.
#### columnTwoStyles field
- Type: string
- Description: Provide custom styles for the second column of the triple-column layout of the email template.
#### columnThreeContent field
- Type: string
- Description: Contains the content that will be rendered in the third column of the triple-column layout of the email template.
#### columnThreeStyles field
- Type: string
- Description: Provide custom styles for the third column of the triple-column layout of the email template.
#### styles field
- Type: React.CSSProperties
- Description: Provide custom styles for the wrapper component
#### pX field
- Type: number
- Description: Numerical value for padding-left and padding-right.
#### pY field
- Type: number
- Description: Numerical value for padding-top and padding-bottom.
The provided React-email components and default styling are designed to work well across various email clients and providers. However, due to the inconsistent support for modern web standards in different email clients, it's recommended to test your email templates in multiple clients to ensure compatibility.
The following email clients are known to be supported:
| |
|
|
|
|
|
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Gmail ✔ | Apple Mail ✔ | Outlook ✔ | Yahoo! Mail ✔ | HEY ✔ | Superhuman ✔ |
Contributions to responsive-react-email are welcome! If you find a bug, have suggestions for improvements, or want to add new features, feel free to open an issue or submit a pull request. Please make sure to follow the existing coding style and conventions.
When submitting a pull request, provide a clear description of the changes made and ensure that all tests pass. Adding appropriate tests for new features or bug fixes is highly appreciated.
For bugs and feature requests, please create an issue.
- Paul Ehikhuemen (@pauloe_me)
responsive-react-email` is licensed under the MIT License.