_Email.md_

Frontmatter

Override theme values and set metadata per-email using YAML frontmatter.

Add a YAML frontmatter block at the top of your markdown to override theme values and set metadata per-email:

---
preheader: "Don't miss our biggest sale"
brand_color: "#e11d48"
button_color: "#059669"
---

# Sale Starts Now

Everything is 50% off this weekend.

::: footer
**Acme Corp** · [Unsubscribe](https://example.com/unsub)
:::

Frontmatter uses snake_case keys. They map directly to the same theme options available in the JS API (which uses camelCase).

Preheader

The preheader field sets the preview text that email clients show in the inbox list next to the subject line. It's hidden in the email body itself:

---
preheader: "Your order has shipped — track it now"
---

Selecting a Theme

Use theme to switch the base theme for a single email. Individual overrides still layer on top:

---
theme: dark
brand_color: "#e11d48"
---

# Dark email with a custom brand color

Valid values: light (default), dark.

Custom Fonts

Embed custom web fonts (e.g. Google Fonts) with a nested fonts: map. Each entry is a family name → stylesheet URL, rendered as a <mj-font> tag so the font loads in clients that support embedded web fonts (Apple Mail, iOS Mail):

---
fonts:
  Inter: "https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap"
  Merriweather: "https://fonts.googleapis.com/css2?family=Merriweather"
font_family: "Inter, sans-serif"
---

# Hello

The font still needs to be named in font_family (or via fontFamily in code) to actually apply to text. MJML only injects a <link> for fonts referenced in the compiled CSS, so unused entries are silently dropped.

When both the fonts: frontmatter and the fonts render option are provided, frontmatter wins on matching family names and non-overlapping entries merge together.

All Frontmatter Keys

KeyDescription
preheaderInbox preview text (hidden in email body)
themeBase theme — light or dark
brand_colorLinks, highlights, accents
heading_colorHeading text color
body_colorBody text color
background_colorOuter background color
content_colorContent area background
card_colorCallout / code block background
button_colorPrimary button background
button_text_colorButton text color
secondary_colorSecondary button border
secondary_text_colorSecondary button text
success_colorSuccess button background
success_text_colorSuccess button text
danger_colorDanger button background
danger_text_colorDanger button text
warning_colorWarning button background
warning_text_colorWarning button text
font_familyFont stack
font_sizeBase font size
line_heightBase line height
content_widthEmail content width
border_radiusBorder radius for buttons, callouts, highlights
fontsNested map of custom web fonts: family name → stylesheet URL

Custom Metadata

Any keys beyond the ones above are passed through in the meta object returned by render(). This is useful for storing email metadata alongside the template:

---
preheader: "Welcome aboard"
subject: "Welcome to Acme"
campaign_id: "onboarding-v2"
---

# Welcome!
const { html, text, meta } = await render(markdown);

console.log(meta.subject);     // "Welcome to Acme"
console.log(meta.campaign_id); // "onboarding-v2"
console.log(meta.preheader);   // "Welcome aboard"

On this page