Skip to content

Navigation

TableOfContents

“On this page” list of jump links to the page's headings.

  • Experimental
  • Keyboard not tested yet
  • Screen reader not tested yet

Updated 2026-11-12

Playground

Change the props. The controls come from the documented props.
tsx
<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.
  1. titleSmall semibold title.
  2. 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.
TableOfContents props
NameTypeDefaultDescription
items (required)TocItem[]–id, title and depth (2 or 3) per heading.
labelstring"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.
Tokens used by TableOfContents
TokenTierValueUtility
link.radiuscomponent4px
toc.bordercomponentrgba(10,10,11,0.08)
toc.fgcomponent#555555
toc.fgHovercomponent#0A0A0B
focussemantic#C6492E
spacing.2semantic8px
spacing.3semantic12px
spacing.6semantic24px
surface.pagesemantic#FAFAF7
text.primarysemantic#0A0A0B
type.small.sizesemantic14px
weight.semiboldsemantic600

Accessibility

What is checked automatically on every build, and what a person has tested. Nothing is marked as tested unless it was.
Testing status by check
CheckHowStatus
axe-core rulesAutomated on every npm run check, at desktop and mobile widthRuns on every build
KeyboardAutomated Playwright test (scripts/keyboard.mjs)Not tested yet
Screen readerManualNot tested yet

Keyboard

TableOfContents keyboard interactions
KeyAction
TabMoves through the jump links.

Semantics and focus

  • A named <nav> landmark with plain anchor links.

Contrast

TableOfContents contrast pairings
PairingRatio (x:1)MinimumStatus
text.primary on surface.page18.924.5Pass
text.secondary on surface.page7.134.5Pass
focus on surface.page4.573.0Pass