Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
paths: - "packages/documents/src/email/" - "packages/jobs/src/inngest/functions/notifications/" - "packages/jobs/src/inngest/functions/tasks/changelog-dispatch*"
Email Design — every email is the notification card
Carbon sends one kind of email: the card that NotificationEmail renders
(packages/documents/src/email/NotificationEmail.tsx). Transactional, lifecycle, and
broadcast emails (MfaRequiredEmail, ChangelogEntryEmail, …) are
the same card with different copy. A new email that looks different from a notification
is a bug, not a design choice. Grounded in the templates and components/ in that folder.
Where things live
| What | Where |
|---|---|
| Templates | packages/documents/src/email/*.tsx, exported from index.ts → @carbon/documents/email |
| Shared chrome | components/Theme.tsx (EmailThemeProvider, getEmailThemeClasses, Geist font, dark-mode meta), components/Logo.tsx, components/notificationStyles.ts (the nf-* classes), components/DocumentCard.tsx (the document emails' card, held to 600px in classic Outlook) |
| Rendering | jobs code: render(SomeEmail({ ...props })) with import { render } from "react-email" — a plain function call, no JSX in @carbon/jobs |
| Sending | the carbon/send-email event (notifications/send-email.ts, needs a companyId) or sendEmail from @carbon/lib/email.server directly for platform mail with no company (tasks/changelog-dispatch.ts) — both go through the shared SMTP transport, which no-ops (data: null) when no SMTP_* / RESEND_API_KEY is configured |
| Previews | src/email/previews/ — one fixture per shipped email, pnpm --filter @carbon/documents email:previews |
Never build email HTML by string concatenation. The changelog emails briefly did; that
is exactly how a template drifts from the card (different font, colors, no dark mode, no
Logo). Write a .tsx template in @carbon/documents, render it in the job.
The card, top to bottom
Copy MfaRequiredEmail.tsx for a single-CTA email or NotificationEmail.tsx when there
are label/value details. Every piece below is load-bearing:
<EmailThemeProvider preview={<Preview>…</Preview>} additionalHeadContent={<style>{notificationStyles}</style>}>— thePreviewis the inbox snippet; thenotificationStylesare what make dark mode work.<Body className="my-auto mx-auto font-sans nf-body …themeClasses.body">.<Container className="my-[40px] mx-auto p-[36px] max-w-[560px] rounded-[16px] nf-card …" style={{ borderRadius: 16, borderStyle: "solid", borderWidth: 1 }}>— 560px, radius 16, 1px border. On a phone (≤ 600px) the card is the whole screen:flatCardOnPhones(notificationStyles.ts) drops its border, corners and outer margin and tightens the padding; an email with its own card class (WeeklyReminderEmail,GetStartedEmail) appends it to its styles, and the document emails includedocumentCardStyles(DocumentCard.tsx).<Logo />—carbon-email-mark.png(ERPpublic/): the white mark on its own dark 80px tile, one image for every client and mode. Gmail's apps and classic Outlook recolour an email themselves and never run the dark CSS, but never recolour an image, so a light/dark logo swap is not used. Itssrcmust be PUBLICLY reachable (the recipient's mail client fetches it): production/preview usegetAppUrl(), anything else (acrbn updev origin, localhost) falls back tohttps://app.carbon.ms. Never delete an image an email has referenced (carbon-word-dark-outline.png): mail already sent still loads it.- Eyebrow —
text-[11px] uppercase … nf-eyebrow,letterSpacing: "0.14em",mt-[40px] mb-[10px]. Names the category: "New notification", "Security", "Changelog". - Heading —
text-[26px] font-medium text-center tracking-tight … mb-[32px]. The action or title, one line. - Greeting —
Hi {recipientName ?? "there"},attext-[15px] leading-[26px]. Only when the recipient is a Carbon user with a name; a bare email address (a changelog subscriber) gets no greeting. - Callout —
<Section className="nf-callout" style={{ backgroundColor: "#fafafa", borderColor: "#ececef", borderRadius: 12, borderStyle: "solid", borderWidth: 1, marginBottom: 28, padding: "18px 20px" }}>with arole="presentation"table inside. For a notification about a RECORD, the message/reference lives here attext-[15px] leading-[24px], with details as label/value rows attext-[13px]split by annf-divider. An announcement with no record (ChangelogEntryEmail) skips the box and sets its description as centered prose under the heading instead. - CTA — one
<Button className="nf-cta" style={{ backgroundColor: "#0e0e0e", borderColor: "#0e0e0e", borderRadius: 10, …, padding: "13px 24px", fontSize: 14, fontWeight: 500 }}>, centered,mb-[24px]. One button per email. - Fallback link — "Or open this link in your browser:" + the raw URL at
text-[13px] … break-all nf-fallback. Always, for clients that strip buttons. - Footer (when the reader might not know why they got it) —
<Hr className="my-[32px] nf-divider …" />thentext-[12px] leading-[18px] … nf-fallback: why they received it + the action link ("Manage notification settings", "Unsubscribe").
Rules that are not style
- No background images, and no page colour in light mode. Gmail's iOS app ignores the dark-mode media queries and inverts the email's colours itself, but never a background image: a
linear-gradientcard stayed white while its text turned white..nf-bodyhas a colour only in dark mode, and.nf-cardis a bordered box on the mail app's own background in light mode. - The dark palette is Gmail's inversion of the light one.
emailTheme.dark(components/Theme.tsx) holds the colours Gmail's iOS app produced from the light palette (page#131314, callout#242527, button#f3f3f3on#202124, muted#9fa7b6), measured from a real screenshot, so Apple Mail (which runs the dark CSS) shows the same email Gmail does. Outlook recolours on its own and never gets this palette. In dark mode the card is the page's colour, set off by its border.notificationStylesandWeeklyReminderEmailread the palette, never hex literals. Change a light colour and its dark twin changes in Gmail on its own: re-measure and updateemailTheme.darkto match. - Every dark rule goes through
darkModeMedia(components/Theme.tsx). Outlook.com and the new Outlook run@media (prefers-color-scheme: dark)from the operating system's theme, not their own (Can I email lists Outlook.com as supporting the query; HTeuMeuLeu: "if your email is displayed in Outlook.com's light mode preview pane, but your operating system is set up in dark mode, all of your dark mode styles will still apply"). A purchase order on Outlook's light pane under a dark Windows got a dark panel and a heading white on white. Outlook prefixes every class withx_in the markup and the CSS, sodarkModeMediaadds:not([class^="x_"])to each selector's first class and refuses a selector with no class; Outlook then does its own dark mode. Outlook.com also drops any rule containing:not()outright (Can I email's:not()test, 2024-01: neither cell styled, where stripping only:not()would have styled both), so the rule cannot reach it either way. Never write a raw@media (prefers-color-scheme: dark)block, and never key a rule on Outlook'sdata-ogsc/data-ogsbor the.gmail_dark/[data-darkmode]selectors: no Gmail client runs the query at all. No Outlook honours thecolor-schememeta tag, solight onlycannot opt out there. - Dark mode is done by CLASS, not inline style. Backgrounds go through
nf-*classes so the!importantmedia-query overrides innotificationStylescan flip them; an inlinebackground-colorbeats them and renders a white card on a black Gmail. Text colors usegetEmailThemeClasses()(email-text,email-muted, …). Off-black#0e0e0eand off-white#fefefe, never pure#000/#fff— pure values get auto-inverted by some clients. - No sample defaults on content props.
NotificationEmaildeliberately givesheading/messageno defaults: fabricated data must never reach a real recipient. Sample data lives in the preview fixture only. (Some older templates —VerificationEmail— still default their props; don't copy that, or their pre-card layout.) - Always send a
textalternative alongsidehtml— the job builds it from the same content (seeentryEmailContentinpackages/jobs/src/inngest/functions/tasks/changelog-dispatch.feed.ts). - Broadcast mail carries a
List-Unsubscribeheader and a footer link to where the reader turns it off. For the changelog newsletter that is the signed-in Account → Notifications page (only the user may change their preference), so there is no one-clickList-Unsubscribe-Postand the email renders once per entry, not per recipient. - Links in customer-authored text are not links unless they pass
renderInlineLinksagainst the ERP origin (NotificationEmaildetails) — anhttps://in a body someone typed stays literal text. - Add the preview fixture in the same change (
previews/<Name>.tsx, props filled with obviously-sample values like "Acme Manufacturing" / "John Doe") — it is the only way anyone sees the email before a customer does.
Checklist for a new email
-
packages/documents/src/email/<Name>Email.tsx, copied fromMfaRequiredEmail.tsxorNotificationEmail.tsx, all eleven pieces present - Exported from
src/email/index.ts -
previews/<Name>Email.tsxfixture - Job renders with
render(NameEmail({ ...props }))— a function call, never JSX — and sendshtml+text(+ unsubscribe headers if broadcast) -
pnpm --filter @carbon/documents typecheckandemail:previewschecked in light AND dark