---
title: "Brand your emails"
description: "Give every email your app sends one branded layout: your name or logo, your colors and fonts in light and dark, the postal address marketing email needs, and ready blocks (kicker, heading, code, button, note) for emails of your own."
canonical_url: "https://nuxt-backend.dev/docs/build/email/templates/theme"
---
# Brand your emails

> Give every email your app sends one branded layout: your name or logo, your colors and fonts in light and dark, the postal address marketing email needs, and ready blocks (kicker, heading, code, button, note) for emails of your own.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- **You get:** every email in one layout with your name or logo, your colors and fonts in light and dark, the postal address marketing needs, and blocks for emails of your own.
- **Powered by:** plain HTML with inline styles, rendered on your deployment. Resend sends what the layout produces.
- **The package adds:** the layout, the themed blocks with a plain-text version written for you, and one brand shared with your pages.

Make every email look like your app, the ones the package sends and your own. One layout wraps them all: your name or logo at the top, the message on a card, a footer that says who sent it. Give it your colors and fonts, and build your own emails from its blocks instead of hand-written HTML.

## What every email looks like

The layout is plain HTML with inline styles and no stylesheet to load, so it renders the same in every mail client:

- **A header** with your logo, or your name, linked to `SITE_URL`.
- **The message** on a card at most 560 px wide.
- **A footer**, "Sent by Panels", and the same footer at the end of the plain-text version.

Each email reads well in both color schemes. Light is the default, chosen to survive the clients that invert colors on their own, such as Gmail's apps. Dark applies where the client honors `prefers-color-scheme` (Apple Mail, iOS, Outlook for Mac, Thunderbird) and in Outlook.com's dark mode. The document carries the reader's language and its direction, `dir="rtl"` for Arabic, Hebrew and Persian.

A sign-in code stays out of the hidden preview text, which a locked screen shows. Every other email previews its first sentence.

## Your name and logo

Name the app the emails are sent for on `setupEmail`:

```ts [backend/email.ts]
export const email = setupEmail(components, {
  brand: { name: 'Panels', logo: '/email-logo.png' },
})
```

Without a `brand.name`, the deployment names the app after the display name of `EMAIL_FROM` (`Panels` in `Panels <hello@auth.panels.app>`), else the host of `SITE_URL`. `logo` is an absolute URL, or a path read against `SITE_URL`. The header shows it 32 px high, in place of the name, which becomes its alt text. Use a PNG with a transparent background that reads on light and on dark.

Better Auth names the app after the same brand: a passkey prompt shows it as the site's name. `email.brand()` returns the name and logo the deployment resolves now.

### Write the brand once

The pages read the brand from `appConfig.backend.brand`, and the backend reads the same brand, so you write it once:

```ts [app/app.config.ts]
export default defineAppConfig({
  backend: {
    brand: { name: 'Panels', logo: '/email-logo.png', address: 'Panels Ltd., 1 Market St, San Francisco, CA 94105' },
  },
})
```

The module writes the name, logo and address you set there as literals to `backend/brand.generated.ts` on every `dev`, `build` and `nuxt prepare`, and the scaffold's `backend/email.ts` passes it on as `setupEmail(components, { paths, brand })`. Commit the file: the backend deploys with it. `npx nuxt-backend doctor` warns when it is missing or out of date (`brand-file`), and `doctor --fix` writes it.

`setupEmail`'s `brand` stays as an override for the emails alone: `brand: { ...brand, name: 'Panels Mail' }`.

### The postal address

Marketing law asks every commercial email for the sender's postal address. `brand.address` puts it in the footer of every email sent under a [topic](https://nuxt-backend.dev/docs/build/email/preferences) and every [announcement](https://nuxt-backend.dev/docs/build/growth/engage/announcements). Transactional email, such as a sign-in code, leaves it out. `npx nuxt-backend doctor --prod` fails when topics are declared and the address is missing.

## Your colors and fonts

`theme` on `setupEmail` sets the layout's colors for each scheme, and its fonts:

```ts [backend/email.ts]
export const email = setupEmail(components, {
  brand: { name: 'Panels', logo: '/email-logo.png' },
  theme: {
    colors: { background: '#fff7e6', card: '#ffffff', text: '#1c1620', accent: '#d500f9', accentText: '#ffffff' },
    dark: { background: '#14111a', card: '#1e1a26', text: '#f4f0f8', accent: '#e36bff', accentText: '#14111a' },
    fonts: {
      heading: "'Archivo Black', 'Arial Black', Arial, sans-serif",
      body: "'Helvetica Neue', Arial, sans-serif",
    },
  },
})
```

- **colors** are the light scheme, as hex colors: the page `background`, the message `card`, its `text`, and the `accent` of buttons, the code block and the kicker, with the `accentText` on a button or a code.
- **dark** takes the same keys for readers in dark mode. Leave a key out, and the layout derives it from `colors`: your `text` becomes the card, a darker step of it the page, your `background` the text, and the accent lightens only as far as it needs to read at 4.5:1 on the dark card (an accent that is your text color follows the text).
- **fonts** are CSS font stacks: `heading` for the heading, the kicker, the code and the name in the header, `body` for everything else. Most mail clients load no web fonts, so end each stack with a font every device has.

Every key is optional: what you leave out keeps the package's default. `setupEmail` refuses a color that is not hex, a font stack with more in it than names, and a key the theme does not have, when your backend loads. Check each pair in both schemes in the DevTools **Email** tab, since a mail client never fixes low contrast for you ([Previewing](https://nuxt-backend.dev/docs/build/email/templates#previewing)).

## Your own emails in the layout

`email.compose` builds an email of your own in the layout, in a reader's language ([Your own emails, translated](https://nuxt-backend.dev/docs/build/email/templates/languages#your-own-emails-translated)). It takes `blocks` in place of `html`: the same parts the packaged emails are made of, themed, with the text version written for you:

```ts [backend/strips.ts]
const message = await email.compose(({ t, brand }) => ({
  to: user.email,
  subject: t('strips.readySubject', { title }),
  blocks: [
    { kicker: t('strips.readyKicker') },
    { heading: title },
    { paragraph: t('strips.readyBody') },
    { button: { label: t('strips.open'), url: `${brand.url}/strips/${stripId}` } },
    { note: t('strips.readyNote') },
  ],
}), { locale: user.locale })

await email.send(ctx, message)
```

<table>
<thead>
  <tr>
    <th>
      Block
    </th>
    
    <th>
      What it renders
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        { kicker }
      </code>
    </td>
    
    <td>
      A short label above the heading, in the accent color
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        { heading }
      </code>
    </td>
    
    <td>
      The email's title
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        { paragraph }
      </code>
    </td>
    
    <td>
      A paragraph of text
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        { code }
      </code>
    </td>
    
    <td>
      A one-time code on a plate of its own, in large, spaced type
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        { button: { label, url } }
      </code>
    </td>
    
    <td>
      One call to action
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        { note }
      </code>
    </td>
    
    <td>
      Quiet small print under the action
    </td>
  </tr>
</tbody>
</table>

Every value is text: the layout escapes it, so a strip title cannot put markup into the email, and a line break in a paragraph or a note stays one. A button's URL must start with `https://`, `http://` or `mailto:`. The text version lists the blocks in order, a button as `Label: url`; pass `text` to write it yourself. The hidden preview text is the first paragraph, else the heading, and never a code; pass `preheader` to set it. An email takes `blocks` or `html`, not both, and a block that is none of the six, or a value that is not text, throws.

The packaged templates are built from the same blocks, so a [template override](https://nuxt-backend.dev/docs/build/email/templates#override-a-template) can rebuild one in a few lines, and the layout renders what it returns:

```ts [backend/email.ts]
export const email = setupEmail(components, {
  templates: {
    welcome: ({ email, name }, { t }) => ({
      to: email,
      subject: t('email.welcome.subject'),
      blocks: [{ kicker: 'Panels' }, { heading: t('email.welcome.greetingNamed', { name }) }, { paragraph: t('email.welcome.body') }],
    }),
  },
})
```

`html` keeps working for an email the blocks don't cover: build it with the `html` tag, which escapes what it interpolates, and `trustedHtml` for a fragment you built with it. The render context's `theme` holds every color and font in effect (`theme.colors.accent`, `theme.dark.accent`, `theme.fonts.body`), so that HTML can wear the brand too.

## Limits

- **No web fonts in most clients.** Gmail, Outlook and most mobile apps ignore `@font-face`, so the fallback at the end of each stack is what most readers see.
- **No CSS for dark mode in some clients.** Gmail's apps invert colors on their own and ignore `prefers-color-scheme`, which is why light is the default.
- **Images may be blocked.** Some clients hide images until the reader allows them, so the logo's alt text, your brand name, carries the header.
- **Your BIMI logo is separate.** The avatar a mailbox shows beside the sender comes from BIMI, set up in DNS, not from this layout ([Show your logo with BIMI](https://nuxt-backend.dev/docs/build/email/delivery/deliverability#show-your-logo-with-bimi)).

## Test it

`renderEmail` from `nuxt-backend/test-utils` renders an email with your `brand` and `theme`, so a test can check that the colors landed:

```ts [backend/email.test.ts]
import { renderEmail } from 'nuxt-backend/test-utils'
import { expect, test } from 'vitest'
import { brand, theme } from './email'

test('the sign-in code wears the accent color', async () => {
  const message = await renderEmail('otp', { email: 'kai@example.com', otp: '493021', type: 'sign-in' }, { brand, theme })
  expect(message.html).toContain(theme.colors.accent)
})
```

Check every scheme by eye too, in the DevTools **Email** tab, at phone width and in dark mode.

## Related

- [Customize email templates](https://nuxt-backend.dev/docs/build/email/templates): the emails the layout wraps, and how to preview them.
- [Send email in each reader's language](https://nuxt-backend.dev/docs/build/email/templates/languages): the words inside the layout.
- [Let people choose their emails](https://nuxt-backend.dev/docs/build/email/preferences): the topics whose emails carry the postal address.
- [Restyle with tokens](https://nuxt-backend.dev/docs/build/ui/customize/tokens): the same brand on your pages.
- [Get email into inboxes](https://nuxt-backend.dev/docs/build/email/delivery/deliverability#show-your-logo-with-bimi): the logo beside the sender's name.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
