Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for custom Head Tags #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ An image, without any pesky borders, outlines, or underlines by default. Require
## Head CSS and Media Queries
You can pass a string prop `headCSS` to your `<Email>` component. You can see it in our [kitchenSink.jsx](https://github.com/chromakode/react-html-email/blob/master/examples/kitchenSink.jsx) example.

## Head Tags
You can pass a react node prop `headTags` to your `<Email>` component if you want to append more tags to the head element. (for example, if you want to add a custom font-family):

```
<Email
title={title}
headCSS={css}
headTags={<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,500" rel="stylesheet"/>}
>
```

## Mailchimp attributes
If you're using Mailchimp and need to add their custom `mc:edit` attributes to your markup, we recommend using the [mailchimpify](http://github.com/Roilan/mailchimpify) module.

Expand Down
3 changes: 3 additions & 0 deletions src/components/Email.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function Email(props) {
<meta httpEquiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{props.title}</title>
{props.headTags}
{props.headCSS && <style type="text/css">{props.headCSS}</style>}
</head>
<body
Expand Down Expand Up @@ -45,6 +46,7 @@ Email.propTypes = {
cellSpacing: PropTypes.number,
style: EmailPropTypes.style,
headCSS: PropTypes.string,
headTags: PropTypes.node,
width: PropTypes.string,
align: PropTypes.oneOf(['left', 'center', 'right']),
valign: PropTypes.oneOf(['top', 'middle', 'bottom']),
Expand All @@ -62,6 +64,7 @@ Email.defaultProps = {
cellSpacing: undefined,
style: undefined,
headCSS: undefined,
headTags: undefined,
bodyStyle: undefined,
children: undefined,
}