Back to React Email

Font

apps/docs/components/font.mdx

0.0.152.0 KB
Original Source

import Support from '/snippets/support.mdx'

Install

Install component from your command line.

<CodeGroup>
sh
npm install @react-email/components -E

# or get the individual package

npm install @react-email/font -E
sh
yarn add @react-email/components -E

# or get the individual package

yarn add @react-email/font -E
sh
pnpm add @react-email/components -E

# or get the individual package

pnpm add @react-email/font -E
</CodeGroup>

Getting started

Add the component to your email template. This applies your font to all tags inside your email. Note, that not all email clients supports web fonts, this is why it is important to configure your fallbackFontFamily. To view all email clients that supports web fonts see

jsx
import { Font, Head, Html } from "@react-email/components";

const Email = () => {
  return (
    <Html lang="en">
      <Head>
        <Font
          fontFamily="Roboto"
          fallbackFontFamily="Verdana"
          webFont={{
            url: "https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2",
            format: "woff2",
          }}
          fontWeight={400}
          fontStyle="normal"
        />
      </Head>
    </Html>
  );
};

Props

<ResponseField name="fontFamily" type="string"> The font family you want to use. If the webFont property is configured, this should contain the name of that font </ResponseField> <ResponseField name="fallbackFontFamily" type="string"> The fallback font family the system should you, if web fonts are not supported or the chosen font is not installed on the system. </ResponseField> <ResponseField name="webFont" type="{url: string, format: string} | undefined"> The webFont the supported email client should use </ResponseField> <ResponseField name="fontWeight" type="number | string"> The weight of the font </ResponseField> <ResponseField name="fontStyle" type="string"> The style of the font </ResponseField> <Support/>