Headings

The five heading roles, each with its size and weight fixed.

Overview

Any title on a page: the public headline, the page title, a section, a subsection, a dialog.

Scale

Do

Quotes

Open

Awaiting reply

Three quotes are waiting on the customer.

import {
  Body,
  PageHeading,
  SectionHeading,
  Stack,
  SubsectionHeading,
} from "@hackcove/ui";

<Stack gap="sm">
  <PageHeading>Quotes</PageHeading>
  <SectionHeading rule>Open</SectionHeading>
  <SubsectionHeading>Awaiting reply</SubsectionHeading>
  <Body as="p">Three quotes are waiting on the customer.</Body>
</Stack>
One PageHeading names the page, SectionHeading its parts and SubsectionHeading what is inside a part.
Don't

Quotes

Three quotes are waiting on the customer.

Open

Two quotes are open.

import { Body, PageHeading, Stack } from "@hackcove/ui";

<Stack gap="sm">
  <PageHeading>Quotes</PageHeading>
  <Body as="p">Three quotes are waiting on the customer.</Body>
  <PageHeading>Open</PageHeading>
  <Body as="p">Two quotes are open.</Body>
</Stack>
PageHeading is an h1, and a page has one. A second one for a section breaks the outline: use SectionHeading.

Hero

Do

Tools for people who build

The supporting sentence that sits under the headline.

import { Display, Lead, Stack } from "@hackcove/ui";

<Stack gap="xs">
  <Display>Tools for people who build</Display>
  <Lead>The supporting sentence that sits under the headline.</Lead>
</Stack>
Display is the one headline at the top of a public page, with a Lead under it.
Don't

Dashboard

Recent activity

Nothing has changed since yesterday.

import { Body, Display, PageHeading, Stack } from "@hackcove/ui";

<Stack gap="sm">
  <PageHeading>Dashboard</PageHeading>
  <Display as="h2">Recent activity</Display>
  <Body as="p">Nothing has changed since yesterday.</Body>
</Stack>
Display is marketing scale, not a section title: inside a page it dwarfs everything around it. Use SectionHeading.

Usage

  • A page has one title: PageHeading for an app page, Display for the headline of a public page. A PageHeader already draws the PageHeading and its subtitle, so use it for the top of a page.
  • Name the parts of a page with SectionHeading; rule puts the hairline under it, with the space either side built in.
  • Name what is inside a part with SubsectionHeading: size sm (default) is a form-group caption, base a card title in a header bar, lg a drawer title.
  • ModalHeading is the title of a dialog or drawer, and Dialog and Drawer draw it from their title. Do not place one on a page.
  • Put a Lead under a Display, and a Subtitle under any other heading.
  • Pick the heading for its place in the outline, never for its size. Display is not a big SectionHeading.
  • color takes default, secondary, tertiary, muted or brand for the hierarchy of the text. A heading's meaning is carried by its words, not a colour.
  • as changes the element, only to keep the outline in order, and never the look.

Accessibility

  • Each heading renders a real heading element: Display and PageHeading an h1, SectionHeading and ModalHeading an h2, SubsectionHeading an h3.
  • as swaps the element and keeps the look, so the outline can follow the page without a visual change.
  • id, aria-* and data-* go on the heading element.
  • Dialog and Drawer draw their own ModalHeading and name themselves by it; an EmptyState draws its SectionHeading the same way.

API

Display

Marketing-scale headline — the one line at the top of a public page. h1, text-4xl/tight semibold, primary text, growing to text-6xl on wider screens. PageHeading's scale is deliberately dev-tool sized; a brochure hero needs a display scale, so it gets its own pinned role rather than callers overriding PageHeading's size.


as
Type
ElementType

color

Colour token; each component sets a sensible default.

Type
"brand" | "default" | "muted" | "secondary" | "tertiary"

PageHeading

Page title. h1, text-2xl/8 semibold, primary text.


as
Type
ElementType

color

Colour token; each component sets a sensible default.

Type
"brand" | "default" | "muted" | "secondary" | "tertiary"

SectionHeading

Top-level section header. h2, text-base/6 semibold, primary text. rule sets a hairline under it (the Divider line colour) with the space either side of the line built in.


as
Type
ElementType

color

Colour token; each component sets a sensible default.

Type
"brand" | "default" | "muted" | "secondary" | "tertiary"

rule
Type
boolean

SubsectionHeading

Nested header. h3, text-sm/5 semibold, primary text. size steps it up for a card, drawer or form-group title: sm (default), base (bold) or lg.


as
Type
ElementType

color

Colour token; each component sets a sensible default.

Type
"brand" | "default" | "muted" | "secondary" | "tertiary"

size
Type
"sm" | "lg" | "base"
Default
sm

ModalHeading

Dialog/modal title. h2, text-base/6 semibold, primary text.


as
Type
ElementType

color

Colour token; each component sets a sensible default.

Type
"brand" | "default" | "muted" | "secondary" | "tertiary"