Page header
A page's eyebrow, title, description and actions, with a breadcrumb above and a heading level you choose.
Demo
Usage
import { Breadcrumb, Button, PageHeader, Segmented } from '@tuttn/slant'
// The page's own header: an h1 with an eyebrow, a description and actions.
<PageHeader eyebrow="Workspace at a glance" title="Overview"
description="Live content and team activity in Moss."
actions={<Button variant="primary">New entry</Button>} />
// With the path above it, and the save state as the breadcrumb's status.
// Keep status defined ('' while there's nothing to say) so the live region
// exists before its first message.
<PageHeader breadcrumb={<Breadcrumb items={path} status={saving ? 'Saving…' : saved ? 'Saved' : ''} />}
title={entry.title} actions={<Button onClick={save}>Save</Button>} />
// Children go under the description: a view switch, filters, badges.
<PageHeader title="Content" description="Every entry in every type.">
<Segmented options={views} value={view} onValueChange={setView} label="View" />
</PageHeader>
// A header inside a section or a pane takes a lower level, and a smaller title.
<PageHeader level={2} title="Delivery tokens" actions={<Button size="sm">Create token</Button>} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | — | The page's name, rendered as the heading (`h1` unless `level` says otherwise). |
eyebrow | ReactNode | — | A short line above the title in the label style: the section the page belongs to, or what it is ("Workspace at a glance"). It's part of the heading group, not of the heading's name. |
description | ReactNode | — | A sentence or two under the title, muted. Text renders as a paragraph in the heading group; anything else (a Row of Badges, say) as a div after it. |
actions | ReactNode | — | The page's actions, at the inline end of the title: Buttons, a SplitButton or a Menu. They wrap under the text when the header is narrower than 36rem. |
breadcrumb | ReactNode | — | A Breadcrumb above the heading, with its `status` if the page has one. |
level | 1 | 2 | 3 | 4 | 5 | 6 | 1 | The heading's level. Use 1 for the page's own header, and a lower level for a header inside a page section or a pane. |
children | ReactNode | — | Content under the description: a Segmented view switch, a FilterBar, Badges. |
…rest | HTMLAttributes<HTMLDivElement> | — | className, style, other attributes and the ref go on the root div. The root sets data-level. |
Accessibility
- The title is a real heading,
h1unlesslevelsays otherwise, so the page shows up in a screen reader's heading list. The eyebrow and description are paragraphs in the samehgroup, read before and after it, not part of its name. - The root has no role. The breadcrumb brings its own named
nav; the actions are ordinary buttons in the tab order, after the text in the DOM, so the reading order matches the screen in either direction and at any width. - Name icon-only actions with
aria-label, and keep one primary action per header.
Structure
The root is a div.sl-page-header, not a <header>: at the top level of a page a header element is a banner landmark, and the app's own top bar already is one. Inside it, the breadcrumb (.sl-page-header-breadcrumb) comes first, then a row with the text and the actions, then the children (.sl-page-header-extra). The text is an <hgroup>: the eyebrow as a paragraph, the title as the heading, and a text description as a paragraph. A description that isn't text, a Row of badges say, is a div right after the hgroup, in the same column, since an hgroup holds only paragraphs and its heading.
Heading level
level picks the heading element, h1 by default, and the title's size: 22px at level 1, 18px at level 2, 14px from level 3 down, steps of the type scale. Use one level-1 header per page, and lower levels for headers inside sections, panes and dialogs. The size is --sl-page-header-title-size on the root, so a page can set its own.
Narrow
The root is a container query. Narrower than 36rem, the actions leave the end of the title and wrap onto a line of their own under the text, from the inline start. The header measures itself, not the window, so it lays out the same in a split pane as on a phone. The title wraps (long words break), the description stops at about 70 characters a line, and the actions wrap among themselves.
Breadcrumb and status
Pass a Breadcrumb as breadcrumb; its status is the place for the page's state, “Saving…” and “Saved”, announced politely as it changes. Give the breadcrumb a label of its own when the page has another one.