Skip to content

Heading

Polymorphic heading element (h1-h6) with margin shorthand props.

A semantic heading component that renders as any heading level (h1h6). It includes margin shorthand props for convenient spacing control in email layouts.

Import

tsx
import { Heading } from "@unmail/react";
vue
<script setup>
import { Heading } from "@unmail/vue";
</script>

Usage

tsx
import { Heading } from "@unmail/react";

export function Email() {
  return (
    <>
      <Heading as="h1" mt={16} mb={8}>
        Welcome to our newsletter
      </Heading>
      <Heading as="h2" mx={0} my={12} style={{ color: "#333" }}>
        Latest updates
      </Heading>
    </>
  );
}
vue
<script setup>
import { Heading } from "@unmail/vue";
</script>

<template>
  <Heading as="h1" :mt="16" :mb="8">
    Welcome to our newsletter
  </Heading>
  <Heading as="h2" :mx="0" :my="12" :style="{ color: '#333' }">
    Latest updates
  </Heading>
</template>

Props

PropTypeDefaultDescription
as'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6''h1'The heading level to render.
mnumber | stringMargin on all sides.
mxnumber | stringHorizontal margin (left and right).
mynumber | stringVertical margin (top and bottom).
mtnumber | stringMargin top.
mrnumber | stringMargin right.
mbnumber | stringMargin bottom.
mlnumber | stringMargin left.

All standard HTML heading element attributes are also supported.

How margins work

Margin shorthand props are resolved via the withMargin() utility and applied before the style prop. This means values in style will override margin shorthands if both are specified for the same side.

Notes

  • The component uses React.forwardRef (React) to forward refs to the underlying heading element.
  • Numeric margin values are treated as pixels.

Released under the MIT License.