Doc page
One page anatomy for documentation: an icon, title and summary header, a reading column and an On this page rail that becomes a bar on a narrow pane.
Installation
pnpm add @heyramzi/uiUsage
import { DocPage } from "@heyramzi/ui/components/docs";<DocPage
title="Learnings"
summary="What engagements taught"
headings={[{ id: "what-worked", label: "What worked" }]}
contentsLabel="On this page"
>
<h2 id="what-worked">What worked</h2>
<p>Splitting the call in two.</p>
</DocPage>Keyboard and accessibility
| Key | Does |
|---|---|
| Tab | Moves through the contents list and the page's own links and controls. |
| Space Enter | On a contents item, scrolls to that heading. |
| Esc | Closes the contents menu on a narrow page and returns focus to its button. |
- The title is an h1. The contents is a nav named by contentsLabel, and the current heading reports itself as current.
- On a narrow pane the contents is a button that opens a menu, with focus on the current heading.
- Picking a heading scrolls to it, at once under reduced motion, but focus stays in the contents list.
- Picking from the narrow menu, or a click outside it, closes it and returns focus to its button.
- With reduced motion on, the rail marker and progress line don't animate.
API reference
DocPage
titlerequiredstringsummarystring- One line under the title. Optional: a page with nothing to add leaves it out.
iconComponent<{ class?: string; weight?: "bold"; "aria-hidden"?: boolean | "true" | "false"; }>sectionstring- Where the page lives, as a reader would say it: "Marketing / Reports".
updatedstring- Already worded and localised: "Updated 30 Jul 2026".
actionsSnippet- Room at the right of the title for a page's own controls.
headingsDocHeading[]- Default
[] - The document's h2s, which the contents rail walks. Under two, there's no rail.
contentsLabelrequiredstring- The rail's name: "On this page".
locateLocateHeading- Supplied by a document that lives in a frame; the default reads the DOM by id.
resetKeystring- Changes when the page is swapped without navigation, so the pane returns to the top.
measure"prose" | "wide"- Default
"prose" - The reading column's width. `wide` is for a document that brings tables and boards.
scrollerbindableHTMLElement | null- Default
null - The scroll box, for a document that has to place things inside it.
childrenrequiredSnippet
| Prop | Type | Default |
|---|---|---|
title required | string | |
summary One line under the title. Optional: a page with nothing to add leaves it out. | string | |
icon | Component<{ class?: string; weight?: "bold"; "aria-hidden"?: boolean | "true" | "false"; }> | |
section Where the page lives, as a reader would say it: "Marketing / Reports". | string | |
updated Already worded and localised: "Updated 30 Jul 2026". | string | |
actions Room at the right of the title for a page's own controls. | Snippet | |
headings The document's h2s, which the contents rail walks. Under two, there's no rail. | DocHeading[] | [] |
contentsLabel required The rail's name: "On this page". | string | |
locate Supplied by a document that lives in a frame; the default reads the DOM by id. | LocateHeading | |
resetKey Changes when the page is swapped without navigation, so the pane returns to the top. | string | |
measure The reading column's width. `wide` is for a document that brings tables and boards. | "prose" | "wide" | "prose" |
scroller bindable The scroll box, for a document that has to place things inside it. | HTMLElement | null | null |
children required | Snippet |
OnThisPage
itemsrequiredDocHeading[]activerequiredstring- The id the reader is in.
labelrequiredstring- What the rail is called: "On this page". Passed in so the library holds no copy.
onSelectrequired(id: string) => voidvariant"rail" | "bar" | "ticks"- Default
"rail" - `rail` sits beside the document, `bar` replaces it on a narrow pane, and `ticks` marks each heading in the gutter with a card of headings on hover or focus.
| Prop | Type | Default |
|---|---|---|
items required | DocHeading[] | |
active required The id the reader is in. | string | |
label required What the rail is called: "On this page". Passed in so the library holds no copy. | string | |
onSelect required | (id: string) => void | |
variant `rail` sits beside the document, `bar` replaces it on a narrow pane, and `ticks` marks each heading in the gutter with a card of headings on hover or focus. | "rail" | "bar" | "ticks" | "rail" |