Sections and layout
Layer
Its children over each other, in one box as tall as the tallest: an image with words on it. In an email, an Image with one child over it.
import { Layer } from "@hyper-elements/react";Example
LIVE ON MARCH 18 TEXT OVER THE PICTURE
- infoemail/outlook-degraded
borderRadius on this Layer in classic Outlook: square corners
root.children[0].children[0].style.borderRadius - infoemail/layer-phone
On phones, the email keeps this Layer's height and cuts its image at the sides (a page scales it): give the Layer a height to draw both the same
root.children[0].children[0].style.height
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="x-apple-disable-message-reformatting"><!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--><meta name="format-detection" content="telephone=no,address=no,email=no,date=no,url=no"><meta name="color-scheme" content="light"><meta name="supported-color-schemes" content="light"><!--[if mso]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--><style>table,td{mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse}img{-ms-interpolation-mode:bicubic}a[x-apple-data-detectors]{color:inherit!important;text-decoration:none!important}</style></head><body style="margin:0;padding:0;-webkit-text-size-adjust:100%;background-color:#fff"><div role="article" aria-roledescription="email" style="background-color:#fff;overflow-wrap:break-word;word-break:break-word"><table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#ffffff" style="background-color:#fff"><tr><td align="center"><!--[if mso]><table role="presentation" cellpadding="0" cellspacing="0" border="0" width="520" align="center"><tr><td><![endif]--><table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="max-width:520px"><tr><td><table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td style="padding:24px"><table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td><table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="border-collapse:separate"><tr><td background="https://hyperelements.dev/img/gradient.png" height="197" valign="bottom" style="height:197px;background-image:url("https://hyperelements.dev/img/gradient.png");background-size:cover;background-position:center;background-repeat:no-repeat;border-radius:12px;overflow:hidden"><!--[if mso]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:472px;height:197px"><v:fill type="frame" src="https://hyperelements.dev/img/gradient.png"></v:fill><v:textbox inset="0,0,0,0"><![endif]--><table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td style="padding:24px"><table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td style="padding-bottom:4px"><p style="margin:0;color:#ef4638;font-family:Inter, Helvetica, Arial, sans-serif;font-size:12px;font-weight:700;line-height:18px;mso-line-height-rule:exactly;text-align:left">LIVE ON MARCH 18</p></td></tr><tr><td><h2 style="margin:0;color:#fff;font-family:Inter, Helvetica, Arial, sans-serif;font-size:24px;font-weight:700;line-height:30px;mso-line-height-rule:exactly;text-align:left">Text over the picture</h2></td></tr></table></td></tr></table><!--[if mso]></v:textbox></v:rect><![endif]--></td></tr></table></td></tr></table></td></tr></table></td></tr></table><!--[if mso]></td></tr></table><![endif]--></td></tr></table></div></body></html>Show the code
import { Column, Email, Heading, Image, Layer, Text } from "@hyper-elements/react";
export default function Example() {
return (
<Email width={520} style={{ backgroundColor: "#ffffff", fontFamily: "Inter, Helvetica, Arial, sans-serif", color: "#0f172a", gap: 16 }}>
<Column style={{ padding: 24, gap: 16 }}>
<Layer style={{ borderRadius: 12, alignItems: "end" }}>
<Image src={{ src: "https://hyperelements.dev/img/gradient.png", width: 1200, height: 500 }} alt="" />
<Column style={{ padding: 24, gap: 4 }}>
<Text style={{ color: "#ef4638", fontSize: 12, fontWeight: 700 }}>LIVE ON MARCH 18</Text>
<Heading level={2} style={{ color: "#ffffff", fontSize: 24 }}>Text over the picture</Heading>
</Column>
</Layer>
</Column>
</Email>
);
}Reference
Its children over each other, in one box as tall as the tallest: an image with words on it. In an email, an Image with one child over it.
Holds: Row, Column, Grid, Layer, Svg, Text, Heading, Link, Button, Image, Divider, List, Table, Video, Social, Menu, Html. Drawn in: email, page.
style:
color: color (inherited)fontFamily: fontFamily (inherited)fontSize: a length (a number of px) (inherited)fontWeight: fontWeight (inherited)fontStyle: one of “normal”, “italic” (inherited)lineHeight: lineHeight (inherited)letterSpacing: a length (a number of px) (inherited)textAlign: one of “left”, “center”, “right”, “justify” (inherited)textTransform: one of “none”, “uppercase”, “lowercase”, “capitalize” (inherited)width: a length (a number of px, %)minWidth: a length (a number of px, %)maxWidth: a length (a number of px, %)backgroundColor: colorborder: borderborderRadius: radiusheight: a length (a number of px). Its height: the image under its children covers it, cut at its sides or its top and bottom.alignItems: one of “start”, “center”, “end”, “stretch” (default"start"). Where its children sit in its height, as CSS align-items.justifyItems: one of “start”, “center”, “end”, “stretch” (default"stretch"). Where its children sit across its width, as CSS justify-items: stretched to it by default.flex: flex. In a Row: its share of the width left after children with a width (default 1); “none” takes its own size.
mobile (on phones): fontSize, lineHeight, letterSpacing, textAlign, width, maxWidth, border.