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 { Heading } from "@neshel-ui/typography";Usage
Preview: heading-scale
Heading h2, size 4xl
Heading h3, default size (2xl)
Heading h4, size lg, medium, primary tone
HEADING H5, SIZE SM, WIDE TRACKING
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
| Prop | Type | Default | Description |
|---|---|---|---|
| align | Responsive<TextAlign> | — | Text alignment (logical: start/end). |
| as | E | — | — |
| asChild(required) | boolean | — | — |
| family | FontRole | — | Font role (Heading "display", Paragraph and Caption "body"; Text inherits). |
| leading | Responsive<TextLeading> | — | Unitless line height; defaults to the size's leading. Drives Capsize trimming. |
| measure | TextMeasure | — | Maximum line length: narrow 45ch, comfortable 65ch, wide 80ch. |
| ref | Ref<HTMLElement> | — | — |
| size | Responsive<TextSize> | — | Size token; font-size = token × the font role's cap-height scale. |
| tone | TextTone | — | Colour role paired with the background for contrast (Caption defaults to "muted"). |
| tracking | TextTracking | — | Letter spacing. |
| trim | boolean | true | Capsize trimming of the space above the cap height and below the baseline (default true). |
| truncate | boolean | — | One line with an ellipsis (clips overflow, so trimming is removed). |
| weight | Responsive<TextWeight> | — | Font weight; Heading defaults to "semibold". |
| wrap | TextWrap | — | 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
sizeto "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
asChildon the link's text or put the link inside the heading.