For AI agents: the complete documentation index is available at https://wallarm.github.io/design-system/llms.txt, the full documentation bundle is available at https://wallarm.github.io/design-system/llms-full.txt, and this page is available as Markdown at https://wallarm.github.io/design-system/components/table-of-contents.md.

TableOfContents

Lists the sections of one long page, such as a report, shows which one is being read and jumps to a section on click — reach for Tabs or SegmentedTabs when only one section shows at a time, and Stepper when the sections are steps of a flow. It never tracks scrolling itself: the page passes the active value, usually from the useScrollSpy hook, and the corner button switches to the Minimized view of dashes, whose popover opens on hover or tap.

Source · Storybook

Usage

import { TableOfContents, TableOfContentsItem } from '@wallarm-org/design-system/TableOfContents';

Examples

Numbered

The page passes each number itself — nothing is counted — and it stays on the first line.

Levels

Two levels at most: level={2} indents a subsection under its parent on the same rail.

Minimized

A dash per section, longest for the active one; hover or tap the dashes to read the rows in a popover.

Long labels

Labels wrap to two lines, then end in an ellipsis; the rail grows with the row.

Long list

The list scrolls inside the height its parent gives it, while the header stays put.

With scroll spy

The usual wiring: useScrollSpy reads the scrolling container and feeds value and scrollTo back in.

With segmented tabs

The same hook drives any control that takes a value — here SegmentedTabs across the top of the page.

Props

PropTypeDefaultDescription
valuestring | undefinedThe active item's value. Controlled only — the page owns the active section.
onValueChange((value: string) => void) | undefinedCalled with the item's value on a plain click on an in-page item.
viewTableOfContentsView | undefineddefaultViewControlled view.
defaultViewTableOfContentsView | undefinedfullUncontrolled initial view.
onViewChange((view: TableOfContentsView) => void) | undefined
titlestring | undefinedOn this pageHeader label in the Full view; the accessible name of the nav, the toggle and the popover unless aria-label is passed.
defaultCheckedboolean | undefined
defaultValuestring | number | readonly string[] | undefined
autoFocusboolean | undefined
idstring | undefined
tabIndexnumber | undefined
relstring | undefined
data-testidstring | undefined

TableOfContentsItem

PropTypeDefaultDescription
value *stringSection id. href defaults to #${value}.
level1 | 2 | undefined1Nesting level; level 2 is indented.
numberReactNodeSection number shown before the label, e.g. 1.1.
downloadany
hrefstring | undefined
hrefLangstring | undefined
targetHTMLAttributeAnchorTarget | undefined
typestring | undefined
defaultCheckedboolean | undefined
defaultValuestring | number | readonly string[] | undefined
autoFocusboolean | undefined
idstring | undefined
tabIndexnumber | undefined
titlestring | undefined
relstring | undefined
onChangeChangeEventHandler<T, Element> | undefined
data-testidstring | undefined

Explorer