Skip to main content
OwnDocs

Table of Contents

1 min readStableBeginner

The table of contents provides on-page navigation from every H2 and H3 heading, with a scroll-spy highlight for the section in view. On desktop it is a sticky sidebar; on mobile it becomes a collapsible "On this page" panel.

Quick Start

Headings automatically get id attributes from rehype-slug, so the TOC works without any config.

MDX
MDX
## Section one
 
## Section two

Adding Options

H3 headings are indented under their H2, and the TOC hides itself when a page has fewer than two headings.

Advanced

The desktop scroll-spy uses IntersectionObserver with a -80px 0px -60% 0px root margin for accurate active-section tracking. The mobile panel shows a section count badge and collapses after a link is tapped.

Options

heading depthstringDefault: H2 + H3

Only H2 and H3 headings appear in the TOC.

Was this page helpful?