Email templates as Angular components
Write emails as standalone components with signal inputs. ng-email renders them to the table-based, inline-styled HTML that Gmail, Outlook and Apple Mail expect, with a plain-text version alongside.
- 1
A 600px container table. Centred with align and max-width, so it keeps its width in Outlook and shrinks on phones.
- 2
Rows are nested tables. Email clients lay out tables reliably. Flexbox and grid are dropped by Gmail and Outlook.
- 3
A button Outlook can pad. Outlook ignores padding on links, so conditional comments add spacing only Outlook reads.
From component to inbox
Four commands, in the order you will run them.
1 Install
The renderer and the email components. Both need Angular 22.
npm install @ng-email/render @ng-email/components2 Write
A standalone component with signal inputs. Start from a block and edit the copy.
npx ng-email add header-centered3 Preview
Desktop and mobile widths, the plain-text version and table outlines, with live reload.
npx ng-email preview src/emails/index.ts4 Send
Bundle the emails for any Node service, then hand html and text to your provider.
npx ng-email build src/emails/index.ts
The component, and what it renders
Layout comes from ng-email's components, styles are written inline, inputs are signals. The renderer handles the parts email clients are picky about.
welcome.email.ts
@Component({
selector: 'welcome-email',
imports: [EMAIL_COMPONENTS],
template: `
<html ngeHtml>
<body ngeBody>
<table ngeContainer>
<h1 ngeHeading>Welcome, {{ name() }}</h1>
<a ngeButton [href]="url()"
[ngeStyle]="{ padding: '12px 20px' }">Open dashboard</a>
</table>
</body>
</html>`,
})
export class WelcomeEmail {
readonly name = input.required<string>();
readonly url = input.required<string>();
}const { html, text } = await renderEmailBoth(WelcomeEmail, {
inputs: { name: 'Ada', url: 'https://acme.dev/app' },
});The button, as ng-email writes it
<a
href="https://example.com/verify?token=4f9a2c"
target="_blank"
style="
line-height: 100%;
text-decoration: none;
max-width: 100%;
mso-padding-alt: 0px;
display: block;
text-align: center;
background-color: #111827;
color: #ffffff;
font-family:
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif;
font-size: 16px;
font-weight: 600;
border-radius: 8px;
padding-top: 14px;
padding-right: 24px;
padding-bottom: 14px;
padding-left: 24px;
"
>
<span>
<!--[if mso]>
<i style="mso-font-width: 400%; mso-text-raise: 21px" hidden>
   
</i>
<![endif]-->
</span>
<span
style="
max-width: 100%;
display: inline-block;
line-height: 120%;
mso-padding-alt: 0px;
mso-text-raise: 10.5px;
"
>
Verify email address
</span>
<span>
<!--[if mso]>
<i style="mso-font-width: 400%" hidden>
   ​
</i>
<![endif]-->
</span>
</a>- Padding in Outlook
- Outlook ignores CSS padding on links, so the
<!--[if mso]>blocks add spacing only Outlook reads. - Exact styles
- Inline styles are written as you set them,
mso-*properties included. - Nothing from Angular
- No
ng-version, no component tags, and no comments except the ones email clients use.
Start from a block
21 blocks in 15 categories and 5 complete templates. Copy the code or add it with one command. The files are yours to edit.
Blocks
All components Templates
All templates- WelcomeGreeting, three first steps and a dashboard button.
- Order receiptItems, totals, shipping address and order tracking.
- Password resetReset button, expiry and a "not you?" note.
- Sign-in codeA one-time code with a magic-link fallback.
- Team invitationWho invited them, to which team, and an accept button.