Socket
Socket
Sign inDemoInstall

styled-email-components

Package Overview
Dependencies
27
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    styled-email-components

💌 styled-components for emails


Version published
Weekly downloads
248
decreased by-40.95%
Maintainers
1
Install size
202 kB
Created
Weekly downloads
 

Readme

Source

💌 styled-email-components

npm Version Build Status dependencies Status devDependencies Status

styled-components for emails. This is an extension of original API which adopts React Native like approach of injecting styles.

Motivation

styled-components is a universal styling solution for various target environments with great developer experience and low learning curve. Unfortunately there's no way of using it natively to build React-based emails due to email clients limitations. This module adds all nessecary features to build mail-first components.

Installation

# yarn
yarn add styled-email-components styled-components

# npm
npm install --save styled-email-components styled-components

ℹ️ Don't forget to install styled-components itself as a peer dependency.

Getting Started

styled-email-components uses same syntax to define components:

import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import styled from 'styled-email-components';

const Link = styled.a`
  font-family: sans-serif;
  background: blue;
  color: white;
`;

// That works 😱
console.assert(
  renderToStaticMarkup(<Link href="https://example.com">Hey</Link>),
  '<a href="https://example.com" style="font-family:sans-serif;background-color:blue;color:white;">Hey</a>',
);

Check original Gettings Started for more examples.

Differences

These are key differences compared to original implementation:

  • Styles are set inline
  • styled.* aliases uses XHTML 1.0 Transitional list of elements instead of HTML5
  • Outlook specific styled.vml.*, styled.wml.* and styled.office.* elements are proxied
  • Hex colors are expanded to 6 characters

API

styled-email-components modifies only styled implementation and mirrors rest of API as-is:

License

MIT © Sergey Bekrin

FAQs

Last updated on 26 Jun 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc