Skip to main content
A block of heading text with support for all heading levels (h1-h6).

Installation

npm install @react-email/heading -E

Usage

Add the component to your email template. Include styles where needed.
import { Heading } from "@react-email/heading";

const Email = () => {
  return <Heading as="h1">Lorem ipsum</Heading>;
};

Props

as
'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
default:"h1"
The heading level to render
children
ReactNode
The heading text content
style
React.CSSProperties
Inline styles for the heading
m
string | number
Shorthand for setting all margins
mx
string | number
Horizontal margin (left and right)
my
string | number
Vertical margin (top and bottom)
mt
string | number
Top margin
mr
string | number
Right margin
mb
string | number
Bottom margin
ml
string | number
Left margin

Examples

Different Heading Levels

import { Heading } from "@react-email/heading";

const Email = () => {
  return (
    <>
      <Heading as="h1">Main Title</Heading>
      <Heading as="h2">Subtitle</Heading>
      <Heading as="h3">Section Heading</Heading>
    </>
  );
};

With Custom Margins

import { Heading } from "@react-email/heading";

const Email = () => {
  return (
    <Heading as="h1" mt="24px" mb="16px" style={{ color: "#333" }}>
      Welcome to Our Newsletter
    </Heading>
  );
};

TypeScript

export type HeadingAs = As<'h1', 'h2', 'h3', 'h4', 'h5', 'h6'>;
export type HeadingProps = HeadingAs & Margin;

Email Client Support

This component was tested using the most popular email clients.
GmailApple MailOutlookYahoo! MailHEYSuperhuman

Build docs developers (and LLMs) love