css key in your config.js file:
config.js
Options
Configure how CSS is inlined in your HTML emails.Setting this to For details, see the CSS inlining documentation.
true enables CSS inlining with the default options, or you can pass an object to configure the behavior of the CSS inliner (Juice).config.js
Configure email-safe unused CSS purging.For details, see the CSS Purge Transformer docs.
Control how media queries are handled in your CSS.Setting this to You can also use it to control media query sorting:
true or any non-falsy value enables media query merging:config.js
config.js
Whether to resolve … will be compiled to:This uses See the postcss-calc options.
calc() expressions in the CSS to their computed values.By default, something like this:Maizzle uses a 2-decimal precision when resolving
calc() expressions.postcss-calc to resolve calc() functions in your CSS to their computed values whenever possible. When multiple units are mixed in the same calc() expression, the statement will be output as-is.You may pass an object to configure postcss-calc:config.js
CSS custom properties, or CSS variables, are poorly supported in email clients. Whenever you use them, Maizzle will try to resolve them to their static representation.You may configure this behavior by setting the See the postcss-css-variables options.
resolveProps key to false (to disable it) or to a postcss-css-variables options object:config.js
Rewrites Tailwind CSS class names to email-safe alternatives.See the Safe Class Names Transformer docs.
Configure rewriting of CSS properties to their shorthand form. Disabled by default.See the Shorthand Transformer docs.
Whether to convert 3-digit HEX colors to 6-digit HEX colors. Enabled by default.See the Six HEX Transformer docs.
You’ll probably only need this when using Maizzle programmatically - otherwise you can use the If you want, you can import
@config directive in your CSS to specify a custom Tailwind CSS config file to use.It’s important to note that when using css.tailwind you need to provide a Tailwind CSS configuration object with all values that you need to be different from Tailwind’s defaults. So you need to specify px values, screens etc. that work in email clients:config.js
tailwindcss-preset-email:config.js
tailwind.config.js
Maizzle usestailwindcss-preset-email, a custom preset that configures Tailwind CSS for better email client support.
This preset helps generate more email-friendly CSS, by disabling some of the default Tailwind CSS features that are not well supported in email clients.
For example, HEX values are preferred over CSS variables, and rem units are replaced with px units.
content
By default, Tailwind CSS in Maizzle is configured to scan all.html files in your project’s src directory for classes to generate:
tailwind.config.js
!important
HTML emails still need to use inline CSS, most notably for these reasons:- Outlook/Office 365 for Windows only reads the first class in a
class=""attribute, ignoring the rest. So it’ll only useafromclass="a b" - Some email clients don’t support embedded CSS (i.e. in
<style>) - Embedded styles are often discarded when an email is forwarded
important: true - this way, things like responsive utilities can actually override inline CSS.
Only CSS in
<style> tags will use !important, inlined CSS in style="" attributes will not.important key to false:
tailwind.config.js
separator
Characters like: in hover:bg-black need to be \escaped in CSS.
Because some email clients (Gmail 👀) fail to parse selectors with escaped characters, Maizzle normalizes all your CSS selectors and HTML classes, replacing any escaped characters it finds with email-safe alternatives.
So you can safely use Tailwind’s awesome default separator and write classes like sm:w-1/2 - Maizzle will convert that to sm-w-1-2 in your compiled template.
You may also configure the replacement mappings if you need to.
screens
Maizzle uses a desktop-first approach withmax-width media queries instead of Tailwind’s default, mobile-first approach that uses min-width.
These are the default screens in Maizzle:
tailwind.config.js
tailwind.config.js
md:hidden or md:text-lg, which will be wrapped in a @media (min-width: 768px) and (max-width: 1023px) media query.
More on screens, in the Tailwind CSS docs.
colors
Maizzle uses the default color palette from Tailwind CSS. You may define your own colors, or even extend or change the default color palette by adding acolors key to your Tailwind config:
tailwind.config.js
spacing
The spacing scale has been extended to include more values:borderRadius
boxShadow
The tailwindcss-box-shadow plugin is used to outputbox-shadow CSS values exactly as you have them defined in your Tailwind CSS config.
fontFamily
Font stacks are the default ones from Tailwind CSS, but simplified. We also include a stack for the Inter font:fontSize
Pixel values are preferred for font size utilities:lineHeight
ThelineHeight utilities have been extended to include all spacing scale values:
leading utilities to easily create vertical spacing, like this:
emails/example.html
maxWidth
Pixel units
Because of poor email client support, our email preset for Tailwind CSS replacesrem units with px.
This affects the following utilities:
spacing(width, height, margin, padding, etc)maxWidthborderRadiusfontSizelineHeight
Plugins
You can of course use any Tailwind CSS plugin, all you have to do is to install it from NPM and thenimport or require it in your tailwind.config.js.
import:
tailwind.config.js
require:
tailwind.config.js
tailwindcss-email-variants is already included in the email preset, no need to install it.Disabled plugins
tailwindcss-preset-email disables the following Tailwind CSS core plugins due to poor support in the majority of email clients:
- preflight
- backgroundOpacity
- borderOpacity
- borderSpacing
- divideOpacity
- placeholderOpacity
- textOpacity
- textDecoration
true in corePlugins at the bottom of your tailwind.config.js:
tailwind.config.js