Tailwind
A React component to wrap emails with Tailwind CSS.
Install
Install component from your command line.
Getting started
tailwindcss
version used for this component is 3.4.10
Add the component around your email body content.
Props
Customize the default theme for your project with the available properties in Tailwind docs.
Most email clients are style-limited and some styles may not work.
One example of this is how Tailwind uses rem
as its main unit for
better accessibility. This is not supported by some email
clients, if you want you
can override the Tailwind config.
We can’t really apply this configuration for you as it would have a few drawbacks. In the future, we will probably provide a preset to remediate this. But, for now, here’s a good starter configuration you can use to avoid these issues:
Tailwind configuration with px instead of rem
Tailwind configuration with px instead of rem
Live example
Tailwind Demo
See the full demo and source code.
Support
All components were tested using the most popular email clients.
Gmail
Apple Mail
Outlook
Yahoo! Mail
HEY
Superhuman
Known limitations
No support for contexts inside the component
No support for contexts inside the component
Currently adding a context’s provider inside of the Tailwind component, won’t allow you
to properly call the useContext
in any of the children of it, due to some technical limitations
regarding on how we currently map the classNames into styles.
The current workaround for this right now is to move the context’s provider higher than the Tailwind
component, so that all children inside Tailwind can properly call useContext
with the context.
No support for prose from @tailwindcss/typography
No support for prose from @tailwindcss/typography
We do not yet support prose
, and beyond that, we don’t yet support classes that might
be resolved into selectors that are relatively complex. That is, selectors with more
than a class lookup.
This is because we optimistically look into the selectors for class names
and look these up later on the elements, and since prose
, by using more complicated selectors,
cannot be directly inlined without matching the selectors to the elements, it isn’t able to
match the selectors appropriately.
This also means some other utilities do not work either, like the space-*
utility.
The only exception for this inlining of styles is with media queries, as they are not inlinable. We do not
do the same for hover:
styles though, but since their support is not best, you probably won’t need it.
In the future, we will be inlining all the styles we can by actually matching the selectors against the elements themselves.