EmailComponents

Button

EmailButton renders a call-to-action link for VitNode emails, with the same variants and sizes as the app button.

EmailButton wraps React Email's Button with the variants the app's own button uses, so a call to action in a mail looks like a call to action on the site. It renders an <a>, which is the only thing every mail client agrees to style.

Preview

Six email buttons stacked in a white card under the VitNode logo: a blue Default, a pale Secondary, a bordered Outline, a plain Ghost, a blue Link and a red Destructive

Usage

import { EmailButton } from '@vitnode/core/emails/ui/button'
<EmailButton href="https://vitnode.com/">Default</EmailButton>

Centre it the way the framework's own password-reset mail does - a Section does the alignment, because margins are not to be trusted in email:

<Section className="text-center">
  <EmailButton className="min-w-[200px]" href={resetUrl} size="lg">
    Reset your password
  </EmailButton>
</Section>

Props

Everything an <a> takes, plus two of its own.

Prop

Type

Variants

VariantLooks likeUse it for
defaultSolid primary fill, light textThe one action the email is asking for
secondarySoft tinted fill, dark textA second, lesser action
outlineBorder, page-background fillA neutral action next to a primary one
ghostText only, no fill or borderTertiary actions
linkPrimary-coloured text, no fillInline links styled as buttons
destructiveSolid red fill, white textDelete, revoke, cancel
destructiveGhostRed text, no fillA destructive action that should not shout

Sizes

SizePadding
smpx-3 py-1.5
defaultpx-4 py-2
lgpx-6 py-2.5

Gotchas

The colours come from the template

bg-primary and friends are defined by DefaultTemplateEmail, which wraps your content in a <Tailwind> with VitNode's palette. Drop an EmailButton into a template that builds its own document and the classes resolve to nothing. Templates lists the tokens.

It is a link, not a button

There is no onClick and no type="submit" to reach for - email has no JavaScript. Every action is a URL, which usually means a signed link into your app.

Next