Headingcomponent

Heading({ level = "2", children, ...props }: HeadingProps): ReactElement
ParamType
propsHeadingProps
Props shared by <Title>, Heading, and <Subheading> — colour, space, and typography variants plus a heading-level override. required
    .level"1"
"2"
"3"
"4"
"5"
"6"
1
2
3
4
5
6
Heading level (16) — sets the rendered <h1><h6> tag.
Avoid overriding this in practice: pick the component that matches the level — <Title> (<h1>), Heading (<h2>), or <Subheading> (<h3>) — so the visual size and the document outline stay in step.
Return
ReactElement
Rendered <h2> heading element.

Section heading — renders an <h2>.

A section heading — renders an <h2>. It sits in the middle of the three-level heading family: <Title> (<h1>), Heading (<h2>), <Subheading> (<h3>).

Things to know:

  • Pick the component that matches the level rather than overriding level. Choosing <Title> / Heading / <Subheading> keeps the visual size and the document outline in step, which matters for accessibility and the docs-site table of contents.
  • The level prop (16) is an escape hatch for the rare case where the outline level must differ from the visual size — avoid it in normal use.
  • Inside <Prose>, an <h2> is styled by the same rules (the shared .prose styling), so Markdown-rendered headings match component ones.
  • Accepts color= and the typography variants; like all block components it collapses its outer margin when it's the first/last child of its container.

Usage

Section heading

tsx
import { Heading, Paragraph } from "shelving/ui";

<Heading>Billing</Heading>
<Paragraph>Manage your plan and payment method.</Paragraph>

The heading family together

tsx
import { Title, Heading, Subheading } from "shelving/ui";

<Title>Account</Title>        {/* <h1> */}
<Heading>Security</Heading>   {/* <h2> */}
<Subheading>Sessions</Subheading> {/* <h3> */}

Coloured heading

tsx
import { Heading } from "shelving/ui";

<Heading color="red">Danger zone</Heading>

Styling

Heading exposes hooks for its rhythm and type. It inherits text colour by default (so it picks up the surrounding tint); set --heading-color only to override that.

VariableStylesDefault
--heading-tintTint anchor for the heading scopeinherit (flows from color= / parent)
--heading-colorText colourinherit
--heading-space-beforeTop marginvar(--space-section) (2rem)
--heading-spaceBottom marginvar(--space-paragraph) (16px)
--heading-fontFont familyvar(--font-title)
--heading-weightFont weightvar(--weight-strong) (700)
--heading-sizeFont sizevar(--size-xxlarge)
--heading-leadingLine heightvar(--leading)

Global tokens it reads: --space-section, --space-paragraph, --font-title, --weight-strong, --size-xxlarge, and --leading. (<Title> and <Subheading> share this component and expose the parallel --title-* / --subheading-* hooks.)

css
/* Theme: serif headings, a touch larger. */
:root {
  --heading-font: var(--font-serif);
  --heading-size: var(--size-xxxlarge);
}

Examples

<Heading>Section title</Heading>