Quick Reference
Every public export, every render function, every commonly-used prop. One page, links out to deeper explanations where you need them.
All Public Exports
import {
// Wrappers
Email,
Page,
Document,
Body,
// Layout
Row,
Column,
ColumnLayouts,
validateColumnLayout,
// Content
Heading,
Paragraph,
Button,
Image,
Divider,
Video,
Html,
Table,
Social,
Menu,
// Render functions
renderToHtml,
renderToHtmlParts,
renderToPlainText,
renderToJson,
renderRowToJson,
// Config
UnlayerProvider,
useUnlayerConfig,
DEFAULT_CONFIG,
// Utilities
htmlToTextJson,
} from '@unlayer/react-elements';
import type {
EmailProps,
PageProps,
DocumentProps,
RowProps,
ButtonProps,
HeadingProps,
ParagraphProps,
ImageProps,
DividerProps,
VideoProps,
HtmlProps,
TableProps,
SocialProps,
MenuProps,
ColumnLayout,
ValidColumnLayout,
HtmlParts,
UnlayerConfig,
UnlayerProviderProps,
DesignJSON,
DesignBody,
DesignRow,
DesignColumn,
DesignContent,
Href,
Icons,
VideoSource,
TextAlign,
LinkStyle,
SocialIcon,
MenuItem,
// Per-component value types (escape hatch via the `values` prop):
ButtonValues,
HeadingValues,
ParagraphValues,
ImageValues,
DividerValues,
VideoValues,
HtmlValues,
TableValues,
SocialValues,
MenuValues,
BodyValues,
RowValues,
ColumnValues,
ContentValues,
} from '@unlayer/react-elements';
Render Functions
| Function | Signature | Returns |
|---|---|---|
renderToHtml | (element, config?) | string |
renderToHtmlParts | (element, config?) | { head, body } — recommended for email |
renderToPlainText | (element, config?) | string (text/plain MIME part) |
renderToJson | (element) | DesignJSON (root: Body/Email/Page/Document) |
renderRowToJson | (element) | DesignRow (root: Row) |
config overrides UnlayerConfig keys for one render. See Rendering API.
Tree Shape
<Email | Page | Document | Body> ← exactly one wrapper at the root
<Row layout={ColumnLayouts.X}> ← layout requires matching <Column> count
<Column> ← items must live inside a column
<Heading | Paragraph | Button | ... />
</Column>
</Row>
</...>
Wrappers
| Wrapper | Mode | Use For | Props |
|---|---|---|---|
<Email> | "email" | Email-client safe HTML (tables) | EmailProps = Omit<BodyProps, "mode"> |
<Page> | "web" | Responsive web (div + flexbox) | PageProps = Omit<BodyProps, "mode"> |
<Document> | "document" | Print / PDF | DocumentProps = Omit<BodyProps, "mode"> |
<Body> | configurable | Advanced — dynamic mode or SSR config prop | BodyProps |
Common wrapper props (defaults from the editor schema):
| Prop | Default |
|---|---|
backgroundColor | "#F7F8F9" |
contentWidth | "500px" |
contentAlign | "center" |
contentVerticalAlign | "middle" |
fontFamily | { label: "Arial", value: "arial,helvetica,sans-serif" } |
textColor | "#000000" |
linkStyle | { body: true, linkColor: "#0000ee", linkHoverColor: "#0000ee", linkUnderline: true, linkHoverUnderline: true } |
backgroundImage | { url: "", fullWidth: true, repeat: "no-repeat", size: "custom", position: "center" } |
previewText | — (rendered as hidden 150-char preheader in email mode) |
config | — (Server Components escape hatch) |
UnlayerConfig shape — the type accepted by <UnlayerProvider config>, <Body config>, and the second arg of renderToHtml/renderToHtmlParts/renderToPlainText:
| Key | Type | Default |
|---|---|---|
cdnBaseUrl | string | "https://cdn.tools.unlayer.com" |
mode | "web" | "email" | "document" | "web" |
textDirection | string | — |
mergeTagState | Record<string, any> | — |
toSafeHtml | (text, options?) => string | — |
headConfig | { hasFeature?, getInitialValues? } | — |
Layout
<Row>
| Prop | Type | Default |
|---|---|---|
layout | ColumnLayout | — |
cells | number[] | [1] (when neither layout nor cells is given) |
padding | string | "0px" |
backgroundColor | string | "" |
noStackMobile | boolean | false |
<Column>
| Prop | Type | Default |
|---|---|---|
padding | string | "0px" |
backgroundColor | string | "" |
borderRadius | string | "0px" |
ColumnLayouts
| Preset | Cells |
|---|---|
OneColumn | [1] |
TwoEqual | [1, 1] |
TwoWideNarrow | [2, 1] |
TwoNarrowWide | [1, 2] |
ThreeEqual | [1, 1, 1] |
ThreeNarrowWideNarrow | [1, 2, 1] |
FourEqual | [1, 1, 1, 1] |
FiveEqual | [1, 1, 1, 1, 1] |
For arbitrary ratios, pass cells={[3, 1]} directly. The number of <Column> children must equal the number of cells.
Content Components
<Heading>
| Prop | Default |
|---|---|
headingType | "h1" |
fontSize | "22px" |
fontWeight | 400 |
color | "#000000" |
textAlign | "left" |
lineHeight | "140%" |
level is a runtime alias for headingType but isn't on HeadingProps. Use headingType in typed code.
<Paragraph>
Pass content as children (rich React) or via html (rich HTML string with inline tags <b>, <i>, <u>, <s>, <a>, <code>).
| Prop | Default |
|---|---|
fontSize | "14px" |
color | "#000000" |
textAlign | "left" |
lineHeight | "140%" |
<Button>
| Prop | Default |
|---|---|
backgroundColor | "#0879A1" |
color | "#FFFFFF" |
fontSize | "14px" |
lineHeight | "120%" |
padding | "10px 20px" |
borderRadius | "4px" |
textAlign | "center" |
size (via values) | { autoWidth: true, width: "100%" } |
href accepts a plain string (auto-wrapped) or { name: "web", values: { href, target } }. For fixed-width buttons pass values={{ size: { autoWidth: false, width: '240px' } }}.
<Image>
| Prop | Default |
|---|---|
src | placeholder URL with autoWidth: true, maxWidth: "100%" |
altText (or alt) | "" |
textAlign | "center" |
action | { name: "web", values: { href: "", target: "_blank" } } |
src accepts a plain string (auto-wrapped) or { url, width?, height?, autoWidth?, maxWidth? }.
<Divider>
| Prop | Default |
|---|---|
width | "100%" |
borderTopWidth | "1px" |
borderTopStyle | "solid" |
borderTopColor | "#BBBBBB" |
textAlign | "center" |
<Video>
Use videoUrl="https://..." (YouTube/Vimeo, auto-parsed) or pass values={{ video: { type, videoId, thumbnail } }}.
<Html>
| Prop | Default |
|---|---|
html | "<strong>Hello, world!</strong>" |
<Table>
| Prop | Default |
|---|---|
headers | shorthand — string[] |
data | shorthand — string[][] |
columns | 2 (auto-set from headers.length) |
rows | 2 (auto-set from data.length) |
enableHeader | true |
<Social>
| Prop | Default |
|---|---|
icons | shorthand — { name, url }[] |
iconType | "circle" |
iconSize | 32 |
spacing | 5 |
align | "center" |
<Menu>
| Prop | Default |
|---|---|
items | shorthand — { text, href, target? }[] (target defaults to "_blank") |
layout | "horizontal" |
separator | "" |
align | "center" |
fontSize | "14px" |
Critical Rules
| Rule | Right | Wrong |
|---|---|---|
fontFamily shape | { label: "Arial", value: "arial,helvetica,sans-serif" } | "Arial" |
fontWeight type | 700 | "700" |
| Column count | matches layout exactly | — |
| Item placement | inside <Column> | directly in <Row> |
| Column placement | inside <Row> | directly in wrapper |
| Padding values | "0px" | "0" |
| Paragraph content | html prop or children | text prop (doesn't exist) |
<UnlayerProvider> | wraps a <Body>/<Email>/<Page>/<Document> | wraps just <Row> |
| Server Components | <Body config={...}> or renderToHtml(el, config) | <UnlayerProvider> (it's "use client") |
| Config via render fn | render the wrapper directly: renderToHtml(<Email>...</Email>, cfg) | renderToHtml(<MyEmail />, cfg) — config is dropped on MyEmail unless it forwards |
Common Font Stacks
const sansFont = {
label: 'Sans Serif',
value: 'system-ui, -apple-system, BlinkMacSystemFont, sans-serif',
};
const serifFont = {
label: 'Georgia',
value: "Georgia, 'Times New Roman', Times, serif",
};
const monoFont = {
label: 'Monospace',
value: "'SF Mono', 'Fira Code', 'Roboto Mono', monospace",
};
Multipart Email — End to End
import {
Email,
Row,
Column,
ColumnLayouts,
Heading,
Paragraph,
Button,
renderToHtmlParts,
renderToPlainText,
} from '@unlayer/react-elements';
function Welcome() {
return (
<Email previewText="Welcome aboard!" contentWidth="600px">
<Row layout={ColumnLayouts.OneColumn} padding="20px">
<Column>
<Heading headingType="h1" fontSize="24px">
Welcome!
</Heading>
<Paragraph>Thanks for signing up.</Paragraph>
<Button href="https://example.com">Get started</Button>
</Column>
</Row>
</Email>
);
}
const { head, body } = renderToHtmlParts(<Welcome />);
const text = renderToPlainText(<Welcome />);
await mailer.send({
to: 'jane@example.com',
subject: 'Welcome',
html: `<!DOCTYPE html><html><head>${head}</head>${body}</html>`,
text,
});
See Also
- Quickstart — install to first render in 3 steps
- Wrappers — Email/Page/Document/Body details
- Components — full per-component reference
- Rendering API — all five render functions
- Configuration — UnlayerProvider and SSR
- Limitations — gotchas and email-client constraints