responsive-react-email
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Responsive react email

Description

responsive-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

Table of contents

Installation

Add responsive-react-email to your react-email project.

With yarn

yarn add responsive-react-email

With npm

npm install responsive-react-email

Components

SingleColumn component

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(
          <Html>
            <Head />
            <Preview>Responsive Single Column Template</Preview>

            <Body>
            <Container>
                <SingleColumn children={/* Content goes here */} />

                {/* OR */}

                <SingleColumn>
                    {/* Content goes here */}
                </SingleColumn>

            </Container>
            </Body>
        </Html>
    )
}

export default DemoTemplate

Props

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.

DualColumn component

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(
          <Html>
            <Head />
            <Preview>Responsive Dual Column Template</Preview>

            <Body>
            <Container>
                <DualColumn
                styles={/* Styles for two-column wrapper */}
                columnOneContent={
                    /* Content for the first column */
                }
                columnOneStyles={/* Styles for the first column */}
                columnTwoContent={
                 /* Content for the second column */
                }
                columnTwoStyles={/* Styles for the second column */}
                />
            </Container>
            </Body>
        </Html>
    )
}

export default DemoTemplate

Props

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.

TripleColumn component

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(
          <Html>
            <Head />
            <Preview>Responsive Dual Column Template</Preview>

            <Body>
            <Container>
                <TripleColumn
                styles={/* Styles for two-column wrapper */}
                columnOneContent={
                    /* Content for the first column */
                }
                columnOneStyles={/* Styles for the first column */}
                columnTwoContent={
                 /* Content for the second column */
                }
                columnTwoStyles={/* Styles for the second column */}
                 columnThreeContent={
                 /* Content for the third column */
                }
                columnThreeStyles={/* Styles for the third column */}
                />
            </Container>
            </Body>
        </Html>
    )
}

export default DemoTemplate

Props

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.

Supported Email Clients

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 logo Apple Mail Outlook logo Yahoo! Mail logo HEY logo Superhuman logo
Gmail ✔ Apple Mail ✔ Outlook ✔ Yahoo! Mail ✔ HEY ✔ Superhuman ✔

Contributing

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.

Bugs and Feature Requests

For bugs and feature requests, please create an issue.

Author

License

responsive-react-email is licensed under the MIT License.

Package Sidebar

Install

npm i responsive-react-email

Weekly Downloads

765

Version

0.0.5

License

MIT

Unpacked Size

38.5 kB

Total Files

42

Last publish

Collaborators

  • pauloe_me