Skip to main content

Design system components

TableOfContents

In-article table of contents for h2/h3 sections, with mobile disclosure and active-section indication.

Status: alpha. Group: navigation. Markdown version: /design-system/components/table-of-contents.md

When to use

Use TableOfContents in article layouts when the page exposes multiple h2/h3 sections. Pass extracted heading items and activeId from useTableOfContents; pass onItemClick when the parent owns scroll behavior.

When not to use

  • Do not use for global site navigation; use NavMenuList or SiteTree instead.
  • Do not pass heading levels outside h2/h3 without updating the TOCItem contract.

Look-alikes

  • NavMenuList: Do not use for global site navigation; use NavMenuList or SiteTree instead.
  • SiteTree: Do not use for global site navigation; use NavMenuList or SiteTree instead.

Props

TableOfContents props
PropTypeDefaultDescriptionRequired
itemsTOCItem[]noneArray of headings to display.Yes
activeIdstring | nullnoneCurrently active heading ID.No
stickybooleanfalseMake TOC sticky on scroll.No
onItemClick(id: string) => voidnoneCallback when item is clicked.No
classNamestringnoneCustom className.No

Variants

No variant dimensions and no props with a fixed set of values.

Invalid combinations

The contract records no invalid combinations.

Keyboard

TableOfContents keyboard behaviour
KeyBehaviour
TabReaches the disclosure trigger and each heading button.
Enter / SpaceToggles the mobile disclosure and activates heading buttons.

Rules

Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.

TableOfContents rules
LevelRuleHow it is checked
MUSTARIA: Nav landmark with a localized aria-label.Not yet verified: no evidence record. WCAG 4.1.2.
MUSTARIA: Mobile trigger exposes aria-expanded and aria-controls.Not yet verified: no evidence record. WCAG 4.1.2.
MUSTARIA: Active heading button exposes aria-current='location'.Not yet verified: no evidence record. WCAG 4.1.2.
MUSTRequired stories produce no axe violations at the configured severity.Automated by npm run test:stories:matrix:ci. WCAG 2.5.8.
MUSTThe accessibility tree (role, name, state) matches the committed snapshot for every required story.Automated by npm run test:stories:matrix:ci. WCAG 1.3.1, 4.1.2.
MUSTThe component remains legible and operable under a real browser forced-colors: active pass.Automated by npm run test:stories:hc.
MUSTEvery documented keyboard interaction works as specified.Not yet verified: no evidence record. WCAG 2.1.1, 2.1.2.

Install and import

  • In-repo only. TableOfContents is not exported from @digitaltableteur/react, so there is no public import path.
  • Alpha components are internal and never exported.