Navigation
TableOfContents
“On this page” list of jump links to the page's headings.
- Experimental
- Keyboard not tested yet
- Screen reader not tested yet
Playground
Change the props. The controls come from the documented props.
<TableOfContents
label="Playground contents"
items={[
{ id: "when-to-use", title: "When to use", depth: 2 },
{ id: "how-it-works", title: "How it works", depth: 2 },
{ id: "variants", title: "Variants", depth: 3 },
]}
/>Usage
When to use
Use a table of contents on long pages with three or more sections, so people can see the structure and jump.
When not to use
- On short pages: it repeats what is already visible.
- For navigation between pages: use SideNav.
How it works
A list of jump links to the page's h2 and h3 headings, labelled “On this page”. On large screens it sits in a column next to the content.
Content guidelines
The entries are the headings, unchanged. Two levels are enough.
Do and don’t
Do
- Show it on long pages with three or more sections.
Don’t
- Don't list every h4; two levels are enough.
Anatomy
The parts of the component and what each one does, as in the playground above.
- titleSmall semibold title.
- linkJump link; h3 entries are indented.
Examples
Type-checked, and the same code goes into the AI manifest. Import: import { TableOfContents } from "@/ds";
Two levels
Props
Checked against the component's TypeScript type on every build.
| Name | Type | Default | Description |
|---|---|---|---|
| items (required) | TocItem[] | – | id, title and depth (2 or 3) per heading. |
| label | string | "On this page" | Visible title and accessible name. |
Tokens used
Derived from the utility classes in the component's source. Copy a class with one click.
| Token | Tier | Value | Utility |
|---|---|---|---|
| link.radius | component | 4px | |
| toc.border | component | rgba(10,10,11,0.08) | |
| toc.fg | component | #555555 | |
| toc.fgHover | component | #0A0A0B | |
| focus | semantic | #C6492E | |
| spacing.2 | semantic | 8px | |
| spacing.3 | semantic | 12px | |
| spacing.6 | semantic | 24px | |
| surface.page | semantic | #FAFAF7 | |
| text.primary | semantic | #0A0A0B | |
| type.small.size | semantic | 14px | |
| weight.semibold | semantic | 600 |
Accessibility
What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
| Check | How | Status |
|---|---|---|
| axe-core rules | Automated on every npm run check, at desktop and mobile width | Runs on every build |
| Keyboard | Automated Playwright test (scripts/keyboard.mjs) | Not tested yet |
| Screen reader | Manual | Not tested yet |
Keyboard
| Key | Action |
|---|---|
| Tab | Moves through the jump links. |
Semantics and focus
- A named <nav> landmark with plain anchor links.
Contrast
| Pairing | Ratio (x:1) | Minimum | Status |
|---|---|---|---|
| text.primary on surface.page | 18.92 | 4.5 | Pass |
| text.secondary on surface.page | 7.13 | 4.5 | Pass |
| focus on surface.page | 4.57 | 3.0 | Pass |