Blocks

Button

A link drawn as a button. The Button element's props, styles and an example, in Hyper Elements.

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

Example

Show the code
button.tsx
import { Button, Column, Email, Row } 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 }}>
        <Row style={{ gap: 12, justifyContent: "center" }}>
          <Button
            href="https://example.com/start"
            style={{ backgroundColor: "#ef4638", borderRadius: 8, padding: [12, 22], fontWeight: 600, width: 150, hover: { backgroundColor: "#d93425" } }}
          >
            Get started
          </Button>
          <Button
            href="https://example.com/docs"
            style={{ backgroundColor: "#ffffff", color: "#0f172a", border: "1px solid #cbd5e1", borderRadius: 8, padding: [12, 22], width: 170, hover: { backgroundColor: "#f1f5f9" } }}
          >
            Read the docs
          </Button>
        </Row>
      </Column>
    </Email>
  );
}

Reference

A link drawn as a button.

Holds: text; Span, MergeTag, LineBreak.

Props:

  • href: link (required)
  • title: text. Shown as a tooltip by mail clients and browsers that show one.
  • aria-label: text. What a screen reader says for it, where its text alone doesn’t say enough (“Read more about pricing”).
  • attrs: attributes. More attributes for its link: a class, a data- attribute.

style:

  • color: color (default "#ffffff", inherited, Typography)
  • fontFamily: fontFamily (inherited, Typography)
  • fontSize: a length (a number of px) (default 14, inherited, Typography)
  • fontWeight: fontWeight (inherited, Typography)
  • fontStyle: one of “normal”, “italic” (inherited, Typography)
  • lineHeight: lineHeight (default 1.2, inherited, Typography)
  • letterSpacing: a length (a number of px) (inherited, Typography)
  • textAlign: one of “left”, “center”, “right”, “justify” (default "center", 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 (default {"top":10,"right":20,"bottom":10,"left":20}, Spacing)
  • backgroundColor: color (default "#0879a1", Background)
  • border: border (Border)
  • borderRadius: radius (default 4, Border)
  • boxSizing: one of “border-box”, “content-box” (Size). Whether its width holds its padding and border (border-box), or they go on top of it (content-box).
  • alignSelf: one of “start”, “center”, “end” (Layout). Where it sits in its stack, whatever the stack’s alignItems: on phones too, another place than on desktop.
  • 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.hover: color, backgroundColor.

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