Writes emails, web pages, printed documents, PDFs and images in code using @hyper-elements/react React components. Includes a migration codemod from Unlayer Elements and React Email.
Ships in hyper-elements. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Write emails, web pages, printed documents, PDFs and images in code with Hyper Elements (npm install @hyper-elements/react). This is the package's own guide to its elements at @hyper-elements/react (GUIDE.md in the package), written from their definitions: everything needed to write a design, in short. Every prop's and style's details, with its default: node_modules/@hyper-elements/react/REFERENCE.md.
To test an email in Outlook, Gmail and other clients, a design or any HTML: the email-testing skill has the steps, or run npx @hyper-elements/cli preview emails/welcome.tsx.
@hyper-elements/react, install it: npm install @hyper-elements/react react react-dom, or the same with the project's package manager (pnpm add, yarn add, bun add).node_modules/@hyper-elements/react/GUIDE.md, written for the version installed. grep "hyper-elements guide" node_modules/@hyper-elements/react/GUIDE.md gives its id; this skill's is hyper-elements guide f82a37d3. The same id: this skill is that guide, so read on. Another id, or none: read GUIDE.md and follow it where it differs from this skill.A project may have templates written with Unlayer Elements: they import Body, ColumnLayouts or renderToHtml() from @unlayer/react-elements, and use values, layout, html and style props such as backgroundColor="#fff". Those components aren't in Hyper Elements, a new package: these are its components.
npx @hyper-elements/migrate src/emails --from unlayer-elements lists what it would change, --write replaces the files (only those git can restore) and --report notes.md writes what it noted. It rewrites the imports and the JSX, and keeps props, loops and conditions. The new elements render with await render(element), which is async, in place of renderToHtml(). More: npx @hyper-elements/migrate --help.npm install @hyper-elements/react, and remove @unlayer/react-elements once nothing imports it.npx @hyper-elements/migrate src/emails writes them in these elements and checks each against its original.@hyper-elements/react. A design has one root: Email, Page, Document or Canvas.style={{ … }}, never as props: <Heading style={{ fontSize: 24, color: "#111827" }}>. A number is px; padding takes 16, [12, 24] or "12px 24px". A box's text styles are inherited by what it holds.gap (<Column style={{ gap: 16 }}>), space inside a box its padding.Section and a Column stack their children. A Row puts its children side by side (each Column at its style.width, or an equal share) and stacks them on phones. Grid columns={3} makes rows of three. A Section is a band whose background spans the window; a Column with a background is a card.Heading level={1} and Text hold text; inside them Span styles a run, Link href links one, LineBreak breaks the line and MergeTag name writes a merge tag. No raw HTML (<b>, <br>, <div>) and no html prop.Image src={{ src, width, height }} (the file's size in px) with alt; style.width sets the size shown.src is a public https URL the reader's email client can fetch: the project's own (its CDN, its other templates, its site) or one the person gives you. Never make one up: example.com, a guessed path or a file on this computer shows as a broken image. Where the design needs an image that doesn't exist yet, use a placeholder that loads, at the image's size: https://placehold.co/1200x600/png?text=Product+screenshot (width x height in px). Then tell the person which images to replace. A data: URI works in a Page, Document or Canvas, but Gmail doesn't show one in an Email.<List type="number"> of ListItems. Tables: a Table of TableRows (header on the first) of TableCells, with cellPadding and rowBorder in the Table's style.style={{ fontSize: 24, mobile: { fontSize: 20 } }} (the styles listed under "Phones", where text is fontSize, lineHeight, letterSpacing and textAlign), hidden={{ mobile: true }}; in an Email or a Page. Hover: style={{ hover: { backgroundColor: "#374151" } }} (those under "Hover").await render(element) gives { html, text, diagnostics }; errors throw an ElementsError with the same diagnostics. validate(element) runs the checks without rendering; outline(element) prints the laid-out design (each block, its width, its text).@hyper-elements/react/template.@hyper-elements/email-clients. validate(email, { plugins: [await emailClients()] }) adds what classic Outlook, Gmail, Apple Mail and others remove or change, naming its clients, with a fix (without it, one note: email/more-checks). To test an email in them, await renderInEmailClients(email) gives a preview per client: HTML that shows the email as that client does, in Chromium. It takes any other HTML email too.import { writeFile } from "node:fs/promises";
import { ElementsError, formatDiagnostics, render } from "@hyper-elements/react";
import Welcome from "./welcome";
try {
const { html, diagnostics } = await render(<Welcome />);
await writeFile("welcome.html", html);
console.log(formatDiagnostics(diagnostics)); // warnings and notes, each with what to change
} catch (e) {
if (!(e instanceof ElementsError)) throw e;
console.error(formatDiagnostics(e.diagnostics));
process.exitCode = 1;
}
From the shell (@hyper-elements/cli): npx hyper-elements check emails/welcome.tsx runs these checks on the module's default export and exits 1 on errors (--json for JSON); render writes the HTML and text to out/.
Each of these made an agent's first try fail:
<Email backgroundColor="#fff"> → <Email style={{ backgroundColor: "#fff" }}>. Styles never go as props.<Email style={{ width: 600, padding: 24 }}> → <Email width={600}>, with the padding on a Column (a card) or a Section (a band) inside it. A root's width is a prop, and a root has no padding.items={[{ text: "Home", link: "/" }]} → items={[{ text: "Home", href: "/" }]}. A Menu's items are { text, href }, a Social's icons { name, href }.style={{ marginBottom: 16 }} → gap: 16 on the parent. There are no margins.ColumnLayouts, layout, headingType, altText, html are Unlayer Elements' props, not these: a Row of Columns, level, alt, and text as children.<Image src="https://example.com/logo.png"> → src={{ src: "https://example.com/logo.png", width: 240, height: 80 }}, the file's size. Without it, Outlook shows the file at its own size.mobile={{ fontSize: 20 }}, hover={{ … }}, _hover or md: { … } → style={{ fontSize: 24, mobile: { fontSize: 20 }, hover: { … } }}. Phone and hover styles are blocks of style, and there's one breakpoint: phones.className="secondary" or sx={…} → variant="secondary" (the theme's) or style={{ apply: ["card"] }}.A theme is the brand, written once: defineTheme({ colors, spacing, fontSizes, lineHeights, fonts, radii, elements, styles, formats }), given to a root as theme.
token("colors.primary") is a token's value, or part of one (border: { width: 1, style: "solid", color: token("colors.border") }); inside a theme, and only there, a token is "{colors.primary}": everywhere in a design (a root's style, a scope's tokens) it is token(). Names are letters and digits: nest gray.900.colors.background is the root's background; colors.foreground, fonts.body, fontSizes.body and lineHeights.body are its body text (color, font, size and line height), which Text, table cells and list items inherit: set body text here, not on Text (a style on Text misses table cells). fonts.heading is a Heading's font, colors.primary and colors.primaryForeground a Button's (colors.primary a Link's) and fontSizes.body its size too, colors.border a Divider's.elements.Button: { … } is every Button's default style; by: { level: { 1: { fontSize: 40 } } } sets one by a prop's value (a type scale); variants: { secondary: { … } } are picked with variant="secondary" (a list merges in order).styles: { card: { … } } are named styles: style={{ apply: ["card"], padding: 8 }}. A key an element sets itself also replaces the theme's phone and hover values for it.tokens on a Section, Row, Column or Grid overrides tokens inside it: an inverted band is <Section tokens={{ colors: { background: "#111827", foreground: "#ffffff" } }}>.formats: { email: { … } } overrides it for one kind of root; extendTheme(base, overrides) makes a brand's or a customer's theme from a shared one; declare module "@hyper-elements/react" { interface Register { theme: typeof brand } } types every name.import { Button, Column, defineTheme, Email, Heading, Image, Link, List, ListItem, MergeTag, Text, Row, Span, Table, TableCell, TableRow, token } from "@hyper-elements/react";
// The brand, once: every Email, Page, Document and Canvas that takes it is on brand.
const acme = defineTheme({
colors: { background: "#f4f4f5", foreground: "#18181b", primary: "#111827", primaryForeground: "#ffffff", muted: "#71717a", border: "#e4e4e7" },
fonts: { body: "Inter, Arial, sans-serif" },
elements: {
Heading: { by: { level: { 1: { fontSize: 24, mobile: { fontSize: 20 } } } } },
Button: { borderRadius: 6, hover: { backgroundColor: "#374151" } },
},
styles: { card: { backgroundColor: "#ffffff", padding: 32, gap: 16, borderRadius: 8 } },
});
export default function Receipt() {
return (
<Email theme={acme} previewText="Your Acme receipt" style={{ gap: 16 }}>
<Image src={{ src: "https://example.com/logo.png", width: 240, height: 80 }} alt="Acme" style={{ width: 120 }} />
<Column style={{ apply: ["card"] }}>
<Heading level={1}>
Thanks for your order, <MergeTag name="first_name" />
</Heading>
<Text>
Order <Span style={{ fontWeight: 700 }}>#10482</Span> ships tomorrow. <Link href="https://example.com/orders/10482">Track it</Link>.
</Text>
<Table style={{ cellPadding: [8, 0], rowBorder: { width: 1, style: "solid", color: token("colors.border") } }}>
<TableRow header>
<TableCell>Item</TableCell>
<TableCell style={{ textAlign: "right" }}>Price</TableCell>
</TableRow>
<TableRow>
<TableCell>Linen shirt</TableCell>
<TableCell style={{ textAlign: "right" }}>$48.00</TableCell>
</TableRow>
</Table>
<Row style={{ gap: 16 }}>
<Column>
<Text style={{ fontWeight: 700 }}>Shipping to</Text>
<Text>Ada Lovelace, London</Text>
</Column>
<Column>
<Text style={{ fontWeight: 700 }}>Next steps</Text>
<List type="number">
<ListItem>We pack it</ListItem>
<ListItem>You track it</ListItem>
</List>
</Column>
</Row>
<Button href="https://example.com/orders/10482">View your order</Button>
</Column>
<Text style={{ fontSize: 12, color: token("colors.muted"), textAlign: "center" }}>Acme Inc., 1 Market St, San Francisco</Text>
</Email>
);
}
renderImage(element, options) (@hyper-elements/react/image) writes a Canvas as a PNG (format: "svg" an SVG, scale: 2 twice the pixels). Nothing is fetched: fonts gives each font file by the family the design names (TTF, OTF or WOFF, not WOFF2; one per weight and style used), images each image file by the src the design gives. It gives { image, width, height, diagnostics } (what it drew otherwise: a weight not given, a hover); errors throw an ElementsError.
import { readFile } from "node:fs/promises";
import { Canvas, Heading, Image } from "@hyper-elements/react";
import { renderImage } from "@hyper-elements/react/image";
const { image, diagnostics } = await renderImage(
<Canvas width={1200} height={630} style={{ padding: 64, gap: 24, fontFamily: "Inter", textAlign: "center", justifyContent: "center" }}>
<Image src={{ src: "https://example.com/logo.png", width: 240, height: 80 }} alt="Acme" style={{ width: 120 }} />
<Heading level={1} style={{ fontSize: 64 }}>Launch week</Heading>
</Canvas>,
{
fonts: [{ family: "Inter", src: await readFile("Inter-Bold.ttf"), weight: 700 }],
images: { "https://example.com/logo.png": await readFile("logo.png") },
}
);
* required. text styles: color, fontFamily, fontSize, fontWeight, fontStyle, lineHeight, letterSpacing, textAlign, textTransform. box styles: width, maxWidth, padding, backgroundColor, border, borderRadius.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/hyper-elements:hyper-elementsfrom hyper-elements
npx claudepluginhub hyper-elements/hyper-elements --plugin hyper-elementsOther plugins' skills for the same job