Quick start
Import theEmailTheming plugin and add it to your extensions:
How theming works
Themes are CSS-in-JS style objects that map to email component types (headings, paragraphs, links, buttons, etc.). Each theme defines a set ofCSSProperties for every supported
component.
During composeVueEmail, the EmailTheming
plugin acts as a SerializerPlugin that resolves styles for each node based on its type and
depth in the document tree. These styles are then inlined directly onto the rendered Vuemail
components as style attributes. This is necessary because email clients don’t
reliably support <style> tags or external stylesheets.
The resolved styles are passed to each node’s renderToVueEmail() method via the style
prop, where they can be spread onto the rendered element.
Built-in themes
The editor ships with two themes:
Select a theme with
.configure():
Switching themes dynamically
Use a ref to toggle themes at runtime. Key theEditorProvider on the theme to apply the new one:
The
:key="theme" on EditorProvider makes Vue mount a new editor when the theme changes,
ensuring the new theme is applied cleanly. EmailEditor does this on its own when its theme prop changes.Custom themes
Instead of being limited to built-in presets, you can define custom themes using a CSS-in-JS object that maps component names to styles.Extending a built-in theme
UseextendTheme to start from a built-in theme and override specific styles:
Creating a theme from scratch
UsecreateTheme to build a theme without inheriting from a built-in preset.
When no extends is set, the minimal reset is used as a base:
Passing a theme config inline
You can also pass aThemeConfig object directly to the theme prop without using the
helper functions:
Custom theme values appear in the inspector UI, and users can still tweak them
interactively. The inspector doesn’t distinguish between built-in and custom values.
Theme components
Themes define styles for the following email components:Theme-aware serialization
WhenEmailTheming is in your extensions array, the composeVueEmail function automatically
applies theme styles to the exported HTML. No extra configuration is needed.
Examples
See theming in action with a runnable example:Email Theming
Basic/Minimal/Custom theme toggle with live preview.
Custom Themes
Define custom themes with createTheme and extendTheme.