Skip to Content
Neshel-UI
Typography

Heading

Section headings h1–h6 whose visual size is independent of their level.

Purpose

Heading renders a heading element (h2 by default) with the display font, semibold weight and a size that follows its level unless you set one. It is trimmed with Capsize.

Import

import.tsx
import { Heading } from "@neshel-ui/typography";

Usage

Preview: heading-scale
Preview theme

Heading h2, size 4xl

Heading h3, default size (2xl)

Heading h4, size lg, medium, primary tone

HEADING H5, SIZE SM, WIDE TRACKING
heading-scale.tsx
import { Stack } from "@neshel-ui/layout";
import { Heading } from "@neshel-ui/typography";

/** The element (as) sets semantics; the size sets the visual scale — they are independent. */
export default function HeadingScale() {
  return (
    <Stack space="4">
      <Heading as="h2" size="4xl">
        Heading h2, size 4xl
      </Heading>
      <Heading as="h3">Heading h3, default size (2xl)</Heading>
      <Heading as="h4" size="lg" weight="medium" tone="primary">
        Heading h4, size lg, medium, primary tone
      </Heading>
      <Heading as="h5" size="sm" tracking="wide">
        HEADING H5, SIZE SM, WIDE TRACKING
      </Heading>
    </Stack>
  );
}

API

HeadingProps

HeadingProps
PropTypeDefaultDescription
alignResponsive<TextAlign>—Text alignment (logical: start/end).
asE——
asChild(required)boolean——
familyFontRole—Font role (Heading "display", Paragraph and Caption "body"; Text inherits).
leadingResponsive<TextLeading>—Unitless line height; defaults to the size's leading. Drives Capsize trimming.
measureTextMeasure—Maximum line length: narrow 45ch, comfortable 65ch, wide 80ch.
refRef<HTMLElement>——
sizeResponsive<TextSize>—Size token; font-size = token × the font role's cap-height scale.
toneTextTone—Colour role paired with the background for contrast (Caption defaults to "muted").
trackingTextTracking—Letter spacing.
trimbooleantrueCapsize trimming of the space above the cap height and below the baseline (default true).
truncateboolean—One line with an ellipsis (clips overflow, so trimming is removed).
weightResponsive<TextWeight>—Font weight; Heading defaults to "semibold".
wrapTextWrap—Line wrapping strategy (balance suits headings, pretty paragraphs).

Also accepts the props of: React DOM attributes.

HeadingElement

type HeadingElement = "h1" | "h2" | "h3" | "h4" | "h5" | "h6"

Default size by level: h1 4xl, h2 3xl, h3 2xl, h4 xl, h5 lg, h6 base.

Accessibility

Choose as from the document outline (one h1, no skipped levels), then choose size for the design. Screen-reader users navigate by heading level, not by size.

Common mistakes

  • Using size to "make an h3 look like an h1" while also changing the level for looks: keep the level semantic.
  • Wrapping a Heading in a link: use asChild on the link's text or put the link inside the heading.
Edit on GitHub

On this page