This guide explains how to create HTML email templates using UIx components and send emails from your application.
Email Component System
The saas.common.ui.email namespace provides a set of UIx components specifically designed for creating consistent HTML emails. These components are inspired by React Email but implemented with ClojureScript and UIx.
Available Components
The email component library includes:
html- Root wrapper for email contenthead- Contains head elements like styles and meta tagsbody- Wrapper for all email contentcontainer- Centers content with proper width constraintsheading- A block of heading text (h1-h6)text- Paragraph text with consistent stylingbutton- A link styled as a buttonlink- Styled hyperlinkimg- Image component optimized for email clientsrow- Horizontal layout containercolumn- Column within a rowsection- Content sectionpreview- Sets inbox preview texthr- Horizontal rule dividercode-inline- Displays code snippets with cross-client support
Creating Email Templates
To create an email template:
Import the necessary components:
Define your email template using UIx components:
Convert the UIx components to HTML:
Styling Components
Components accept style maps similar to React's style prop:
For margin utilities, use :m, :mt, :mr, :mb, :ml, :mx, or :my:
Sending Emails
Use the saas.email namespace to send emails:
The email-sender is typically injected via the system's dependency injection:
Email Configuration
The system uses Resend as the email service provider. Configuration is handled via the :services/email Integrant component:
For local development, a mock email sender is used that logs email contents instead of sending actual emails.
Extracting Plain Text
For better deliverability, include both HTML and plain text versions of your email:
Example Email Templates
The library includes pre-built templates:
login-code-email- For sending login verification codes with magic linksverification-email- For account verification (onboarding, password reset)
Example usage:
Last updated