Table of Contents Layout Demo
On this page
This page demonstrates the MarkdownLayout with table of contents enabled. Look to the right to see the automatically generated navigation!
The table of contents provides quick navigation through long documents. It tracks your scroll position and highlights the current section.
The ToC is automatically generated from your markdown headings. It supports hierarchical structure and is fully responsive.
As you scroll through this page, notice how the table of contents updates to show your current position. This uses the IntersectionObserver API for smooth performance.
Enable the table of contents by adding to your frontmatter:
---tableOfContents: true---By default, the ToC includes headings from level 2 to 3. This can be configured in the component.
On smaller screens (below xl breakpoint), the ToC is hidden to prioritize content readability.
This section contains more content to demonstrate scrolling behavior.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis.
- Documentation with multiple sections
- Long-form articles
- Tutorial content
- Reference materials
- Short pages (less than 3 sections)
- Landing pages
- Simple announcements
The table of contents component is based on Starlight’s implementation, providing:
- Smooth scroll behavior
- Active section highlighting
- Keyboard navigation support
- ARIA labels for accessibility