chakra-emailv0.3.0
On this page
  1. Template source

Template examples

Runnable reference templates and their source code.

Basic Welcome Email

A minimal branded welcome email with preview text and a CTA.

Markdown Body Email

A template that wraps a markdown-rendered email body.

Chakra v2 Theme Email

Compatibility example for Chakra UI v2-style theme tokens.

Preview Template And Variants

A complete template with typed preview props and named development variants.

Template source

tsx
import {
  Body,
  Button,
  ChakraEmailProvider,
  Container,
  Head,
  Heading,
  Html,
  Preview,
  Text,
  render,
  renderPlainText,
} from 'chakra-email';

const theme = {
  tokens: {
    colors: {
      brand: {
        500: { value: '#6366f1' },
      },
    },
  },
};

function WelcomeEmail() {
  return (
    <ChakraEmailProvider theme={theme}>
      <Html lang="en">
        <Head />
        <Preview>Your Acme account is ready.</Preview>
        <Body bg="gray.50">
          <Container bg="white" p={6} maxW="600px">
            <Heading as="h1" fontSize="2xl" mb={4}>
              Welcome!
            </Heading>
            <Text color="gray.700" mb={6}>
              Thanks for joining us. Your account is ready.
            </Text>
            <Button
              href="https://example.com/get-started"
              bg="brand.500"
              color="white"
            >
              Get Started
            </Button>
          </Container>
        </Body>
      </Html>
    </ChakraEmailProvider>
  );
}

export async function renderWelcomeEmail() {
  return {
    html: await render(<WelcomeEmail />, { pretty: true }),
    text: await renderPlainText(<WelcomeEmail />),
  };
}

By

Commune Software