Components

<script>
	import {
		Html,
		Head,
		Body,
		Preview,
		Container,
		Section,
		Row,
		Column,
		Heading,
		Text,
		Button,
		Link,
		Img,
		Hr
	} from '@better-svelte-email/components';
</script>

Use Html, Head, and Body at the root, then mix layout and content components for the rest of your email.

Document shell

Html

PropDescription
lang? = 'en'Language attribute
dir? = 'ltr'Text direction
(default slot)Nested components
(attributes)All <html> attributes
PropDescription
(default slot)Meta tags, styles, or fonts
(children)Standard <head> children only; no custom props

Body

PropDescription
(default slot)Email content
(attributes)All <body> attributes (class, style, etc.)

Preview

PropDescription
preview: stringInbox preview text (required); trimmed to 150 characters
(attributes)Standard <div> attributes

Layout

Container

PropDescription
(default slot)Inner sections
styleMerged with a max-width of 37.5em
(attributes)All <table> attributes

Section

PropDescription
(default slot)Wrapper around content blocks
(attributes)All <table> attributes

Row

PropDescription
(default slot)Column components; groups columns horizontally
(attributes)All <table> attributes

Column

PropDescription
(default slot)Cell content
(attributes)All <td> attributes (align, width, style, etc.)

Typography

Heading

PropDescription
as?Element to render (h1h6, default h1)
m, mx, my, mt, mr, mb, mlMargin shorthands
(default slot)Heading text
(attributes)Remaining <h*> attributes

Text

PropDescription
as? = stringElement type; defaults to <p>
(default slot)Body copy
styleMerged with default font size and line height
(attributes)All <p> attributes
PropDescription
href: stringDestination URL (required)
target? = '_blank'Link target
(default slot)Link text
(attributes)Remaining anchor attributes

Button

PropDescription
href? = '#'Destination URL
target? = '_blank'Link target
pX? = 0Horizontal padding in pixels
pY? = 0Vertical padding in pixels
(default slot)Button content
(attributes)Remaining <a> attributes

Media and dividers

Img

PropDescription
src: stringImage URL (required)
alt: stringAlt text (required)
width: stringWidth (required)
height: stringHeight (required)
(attributes)Additional <img> attributes; custom styles are merged

Hr

PropDescription
(attributes)All <hr> attributes; provided styles are merged