Blocks

Text

A paragraph of text. The Text element's props, styles and an example, in Hyper Elements.

import { Text } from "@hyper-elements/react";

Example

Show the code
text.tsx
import { Column, Email, LineBreak, Link, MergeTag, Text, Span } 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 }}>
        <Text style={{ fontSize: 16, lineHeight: 1.6 }}>
          Hi <MergeTag name="first_name" />, your build <Span style={{ fontFamily: "Menlo, monospace", backgroundColor: "#f1f5f9" }}>#2705</Span> passed.
          <LineBreak />
          <Span style={{ fontWeight: 700 }}>3 templates</Span> changed. <Link href="https://example.com/diff">See the diff</Link>.
        </Text>
      </Column>
    </Email>
  );
}

Reference

A paragraph of text.

Holds: text; PageNumber, Span, Link, LineBreak, MergeTag, Image.

Props:

  • dir: one of “ltr”, “rtl”, “auto”. Its text’s direction, where it differs from the design’s; it starts on that side unless aligned otherwise.
  • fit: { sizes, maxLines } (only in Canvas). In a Canvas: sizes it may be drawn at (a list of px, or { min, max, step }), largest first, and the lines it may take (maxLines). The image draws the largest size that fits.

style:

  • color: color (inherited, Typography)
  • fontFamily: fontFamily (inherited, Typography)
  • fontSize: a length (a number of px) (inherited, Typography)
  • fontWeight: fontWeight (inherited, Typography)
  • fontStyle: one of “normal”, “italic” (inherited, Typography)
  • lineHeight: lineHeight (inherited, Typography)
  • letterSpacing: a length (a number of px) (inherited, Typography)
  • textAlign: one of “left”, “center”, “right”, “justify” (inherited, Typography)
  • textTransform: one of “none”, “uppercase”, “lowercase”, “capitalize” (inherited, Typography)
  • textDecoration: one of “none”, “underline”, “line-through” (Typography)
  • width: a length (a number of px, %) (Size)
  • maxWidth: a length (a number of px, %) (Size)
  • padding: insets (Spacing)
  • backgroundColor: color (Background)
  • border: border (Border)
  • borderRadius: radius (Border)
  • flex: flex (Layout). In a Row: its share of the width left after children with a width (default 1); “none” takes its own size.

style.mobile (on phones): fontSize, lineHeight, letterSpacing, textAlign, width, maxWidth, padding, border.