npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

everydayai-email-generator

v1.0.9

Published

A TypeScript wrapper for MJML to simplify email generation

Readme

Email Generator

A powerful TypeScript wrapper for MJML that simplifies professional email generation with a fluent API, standardised styling, and component-based architecture.

Table of Contents

Installation

npm install everydayai-email-generator

Quick Start

The Email Generator provides a fluent API for building professional emails with consistent styling and responsive design.

import { createEmail } from 'everydayai-email-generator';

// Create a example email with multiple components
const email = createEmail()
  .newSection()
  .header('Monthly Report', 'Performance summary for December 2024')
  .endSection()
  .newSection()
  .textSection('Thank you for your continued partnership. This is an example of a text section with an optional header included', 'Introduction')
  .metricsSection('Key Performance Indicators', [
    { value: '$125,000', description: '+12% vs last month' },
    { value: '248', description: '+8% growth' },
  ])
  .endSection()
  .newSection()
  .barGraphSection('Quarterly Comparison', [
    { label: 'Q1', value: 85 },
    { label: 'Q2', value: 92 },
    { label: 'Q3', value: 78 }
  ])
  .progressBarSection('Annual Target Progress', 73, 'Goal: $500k by year end')
  .endSection();

// Render to HTML
const result = email.render();

Result: Example Email

The resulting HTML can be used with any email service that accepts HTML content and paired with something like Nodemailer to distribute the email.

API Reference

Core Functions

createEmail()

Creates a new EmailBuilder instance with a fluent API for building emails. This is the starting point for building an email.

Returns: EmailBuilder

const email = createEmail();

EmailBuilder Methods

All methods return the EmailBuilder instance for method chaining, enabling a fluent API pattern.

render(options?): RenderResult

Renders the email to HTML using MJML.

Parameters:

  • options (RenderOptions, optional): Rendering configuration (advanced usage)

Returns: RenderResult with html string and optional errors array

const result = email.render({ minify: true, beautify: false });

getMjml(): string

Gets the raw MJML markup for the email without rendering to HTML.

Returns: string - The complete MJML document

const mjmlMarkup = email.getMjml();

Components

Section Layout Components

Control the visual grouping and separation of email sections. All components are rendered with white rectangular backgrounds that can be chained together. To create different email sections using visual grouping for separation of content, you can use the newSection() and endSection() methods.

newSection(): EmailBuilder

Starts a new email section with rounded top corners and proper spacing.

Features:

  • Creates visual separation from previous content/starts the email
  • Rounded top corners only
  • Proper margin and padding
  • White background

endSection(): EmailBuilder

Ends an email section with rounded bottom corners and proper spacing.

Features:

  • Creates visual separation for next content
  • Rounded bottom corners only
  • Proper margin and padding
  • Complements newSection() for grouped content

Example (With and without sectioning): Take this example of a simple email with no sectioning:

const email = createEmail()
      .header('Here\'s some components with no sectioning', 'This is a subtitle')
      .textSection('This is a text section with an optional header included', 'Introduction')
      .metricsSection('Key Performance Indicators', [
        { value: '$125,000', description: '+12% vs last month' },
        { value: '248', description: '+8% growth' },
      ])
      .textSection('This is a text section explaining the bargraph without an optional header included')
      .barGraphSection('Quarterly Comparison', [
        { label: 'Q1', value: 85 },
        { label: 'Q2', value: 92 },
        { label: 'Q3', value: 78 }
      ])

No Sectioning Visual Example:

Example Email

And now with sectioning:

const email = createEmail()
  .newSection()
  .header('Here\'s some components with no sectioning', 'This is a subtitle')
  .endSection()
  .newSection()
  .textSection('This is a text section with an optional header included', 'Introduction')
  .endSection()
  .newSection()
  .metricsSection('Key Performance Indicators', [
    { value: '$125,000', description: '+12% vs last month' },
    { value: '248', description: '+8% growth' },
  ])
  .endSection()
  .newSection()
  .textSection('This is a text section explaining the bargraph without an optional header included')
  .barGraphSection('Quarterly Comparison', [
    { label: 'Q1', value: 85 },
    { label: 'Q2', value: 92 },
    { label: 'Q3', value: 78 }
  ])
  .endSection()

Sectioning Visual Example: Example Email

Header Component

Creates a prominent header section with title and optional subtitle.

header(title: string, subtitle?: string): EmailBuilder

Parameters:

  • title (string): The main header text (required)
  • subtitle (string, optional): Optional subtitle displayed below the title

Features:

  • Large, bold title text
  • Left-aligned layout
  • Optional subtitle with smaller font
  • Consistent spacing and styling

Example:

const email = createEmail()
  .newSection()
  .header('Monthly Performance Report', '2025 Q2')
  .endSection()
  

Visual Example: Example Email


Text Section Component

Creates a content section with formatted text and optional title.

textSection(content: string, title?: string): EmailBuilder

Parameters:

  • content (string): The main text content (required)
  • title (string, optional): Optional section title displayed above content

Features:

  • Readable typography with optimal line height
  • HTML escaping for security
  • Optional section titles
  • Responsive text layout

Example:

const email = createEmail()
  .newSection()
  .textSection('Thank you for your continued partnership with our services.')
  .textSection('Our team has been working hard to improve...', 'Updates')
  .endSection()

Visual Example: Example Email


Metrics Section Component

Creates a dashboard-style metrics display with cards in a responsive grid layout.

metricsSection(title: string, metrics: MetricItem[], subtitle?: string): EmailBuilder

Parameters:

  • title (string): The main section title (required)
  • metrics (MetricItem[]): Array of metric objects (required)
  • subtitle (string, optional): Optional section subtitle

Features:

  • Responsive grid layout
  • Card-based design with rounded corners
  • Support for metric labels, values, and descriptions
  • Consistent spacing and typography

Example:

const email = createEmail()
  .newSection()
  .metricsSection('Key Performance Indicators', [
    { value: '$125,000', description: '+12% vs last month' },
    { value: '248', description: '+8% growth' },
    { value: '3.2%', description: '+0.5% improvement' },
    { value: '42', description: '8 new this month' }
  ], 'Monthly overview')
  .endSection()

Visual Example: Example Email


Table Section Component

Creates a professional data table with headers and rows.

tableSection(title: string, tableData: TableData, subtitle?: string): EmailBuilder

Parameters:

  • title (string): The main section title (required)
  • tableData (TableData): Object containing headers and rows (required)
  • subtitle (string, optional): Optional section subtitle

Features:

  • Responsive table design
  • Header row with distinct styling
  • Mobile-friendly layout

Example:

const email = createEmail()
  .newSection()
  .tableSection('Sales Performance', {
    headers: ['Region', 'Sales', 'Growth'],
    rows: [
      { cells: ['North', '$45,000', '+12%'] },
      { cells: ['South', '$38,000', '+8%'] },
      { cells: ['East', '$52,000', '+15%'] },
      { cells: ['West', '$41,000', '+6%'] }
    ]
  }, 'Regional breakdown')
  .endSection()

Visual Example: Example Email


Bar Graph Component

Creates a visual bar chart with up to 3 bars using company brand colours.

barGraphSection(title: string, bars: BarData[], subtitle?: string): EmailBuilder

Parameters:

  • title (string): The main section title (required)
  • bars (BarData[]): Array of bar data objects, maximum 3 bars (required)
  • subtitle (string, optional): Optional section subtitle

Features:

  • Automatic scaling relative to largest value
  • Company brand colours (blue, green, orange)
  • Responsive bar sizing
  • Label and value display
  • Maximum of 3 bars for optimal readability

Example:

const email = createEmail()
  .newSection()
  .barGraphSection('Quarterly Comparison', [
    { label: 'Q1', value: 85, subtitle: 'Strong start' },
    { label: 'Q2', value: 92, subtitle: 'Peak performance' },
    { label: 'Q3', value: 78, subtitle: 'Seasonal dip' }
  ], 'Performance by quarter')
  .endSection()

Visual Example: Example Email


Progress Bar Component

Creates a visual progress indicator showing percentage completion.

progressBarSection(title: string, percentage: number, subtitle?: string): EmailBuilder

Parameters:

  • title (string): The main section title (required)
  • percentage (number): Progress percentage from 0-100 (required)
  • subtitle (string, optional): Optional section subtitle

Features:

  • Orange fill colour matching brand
  • Rounded rectangle design
  • Percentage validation (0-100)
  • Smooth visual progression
  • Clear percentage display

Example:

const email = createEmail()
  .newSection()
  .progressBarSection('Annual Target Progress', 73)
  .endSection()

Visual Example: Example Email