Skip to Content
Delmare Digital
Guides

Email builder

Build email templates visually with 12 email-safe Puck components and render them to client-compatible HTML.

Build email templates in Puck with 12 email-safe components. Every component renders table-based HTML with inline styles, for the widest email client compatibility.

Quick start

Edit with the email editor config, and render the saved data to an HTML string on the server:

// Visual editor: use emailEditorConfig
import { emailEditorConfig } from '@delmaredigital/payload-puck/email'

<PuckEditor config={emailEditorConfig} /* ...other props */ />
// Server-side rendering: produce the email HTML string
import { renderToEmailHtml } from '@delmaredigital/payload-puck/email'

// subject / previewText / backgroundColor / fontFamily / maxWidth
// are read from the email's root props (edited in the builder).
const puckData = {
  root: { props: { subject: 'Welcome!', previewText: 'Thanks for signing up', backgroundColor: '#f4f4f4' } },
  content: [/* ... */],
}

// Optional second argument: { config } to override the email Puck config.
const html = renderToEmailHtml(puckData)

Server and editor configs

Email configs follow the same split as page configs:

ConfigImportUse it for
emailBaseConfig@delmaredigital/payload-puck/emailServer-side rendering with EmailRenderer or renderToEmailHtml()
emailEditorConfig@delmaredigital/payload-puck/emailThe Puck editor, with interactive fields

Email components

ComponentDescription
EmailWrapperFull-width outer container with background colour or image, and VML Outlook support
EmailSectionCentered content area with max-width, padding and background colour
EmailColumnsTwo- or three-column table layout with a configurable gap
EmailHeadingHeading text (H1 to H4 sizes) with colour, alignment and font family
EmailTextRich text through TipTap, converted to inline-styled email HTML on render
EmailButtonBulletproof button (table plus anchor) for Outlook compatibility
EmailImageResponsive image with optional link, from the Payload media library
EmailSpacerVertical spacing with configurable height
EmailDividerHorizontal rule with colour and thickness options
EmailHeaderLogo image with optional title text
EmailFooterCompany name, address and unsubscribe link
EmailSocialSocial media icon links with configurable platforms

Individual component configs (server, editor and types) are exported from @delmaredigital/payload-puck/email/components.

Rendering

Three levels of rendering, depending on what you need:

ExportReturnsUse it for
renderToEmailHtml(data, options?)A complete HTML document stringSending through an email API (Resend, SendGrid and so on)
EmailRendererA React elementEmbedding in a larger React email component
getEmailDocumentParts(options){ before, after } HTML stringsYour own wrapping around rendered content

Root fields

The email editor config has root fields that control the whole email:

FieldTypeDescription
subjecttextEmail subject line
previewTexttextareaPreview text shown in the inbox before opening
backgroundColorcolour pickerBody background colour
fontFamilyselectWeb-safe font family
maxWidthnumberMaximum content width (400 to 900px, default 600)

Design constraints

Email components are deliberately more limited than page components, because of how email clients render:

  • Table-based layouts only: no flexbox, grid or div layouts.
  • Inline styles only: email clients strip CSS classes and <style> blocks.
  • Web-safe fonts only: no custom font loading.
  • No JavaScript: all interactivity is removed.
  • VML fallbacks: background images use conditional comments for Outlook.

The plugin handles all of these for you. You design visually in Puck, and the server renderer produces compatible HTML.

Custom email components

Follow the same server/editor split, with three files per component:

MyEmail.types.ts
MyEmail.server.tsx
MyEmail.editor.tsx
  1. MyEmail.types.ts: the props interface.
  2. MyEmail.server.tsx: the table-based render. Every <table> must have a <tbody>.
  3. MyEmail.editor.tsx: extends the server config and adds the field definitions.

Server components use inline styles only. @delmaredigital/payload-puck/email exports the helpers the built-in components use: TABLE_ATTRS, FULL_WIDTH_TABLE_STYLE, centeredTableStyle, emailAlign, alignmentToMargin, WEB_SAFE_FONTS, tiptapHtmlToEmailHtml, vmlBackgroundOpen and vmlBackgroundClose. The email CSS converters (colorValueToEmailCSS, paddingValueToEmailCSS, backgroundValueToEmailCSS) come from @delmaredigital/payload-puck/fields.

Edit this page on GitHub

On this page