Email Theming

Theme Modes

email.WithThemeMode(EmailThemeMode.Light);  // Always light
email.WithThemeMode(EmailThemeMode.Dark);   // Always dark
email.WithThemeMode(EmailThemeMode.Auto);   // Follow OS preference

Custom Colors

email.WithAccentColor("#4f46e5", "#a5b4fc");     // Light, Dark
email.WithSurfaceColor("#ffffff", "#0f172a");
email.WithTextColor("#0b1220", "#f8fafc");

Semantic Color Tokens

TokenPurpose
BodyBackgroundBackground behind main container
SurfaceCard/container background
SubtleSurfaceSubtle backgrounds (stripes, chips)
BorderBorders and dividers
TextPrimary text (headings)
BodyTextParagraph text
MutedTextSecondary text
AccentBrand accent (buttons, links)

Dark Mode Implementation

HtmlForgeX.Email uses:

  • @media (prefers-color-scheme: dark) for automatic switching
  • Stable hfx-* CSS class hooks for safe overrides
  • Outlook.com-specific selectors
  • Image dark-mode swapping via WithDarkModeSource()

API Reference