Skip to content

Table of Contents

Free

The headings of a long page as links, with the section you read marked on a rail as you scroll.

  • Base UI
  • React 19
  • Tailwind CSS 4

Added Nov 8, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Put a list of links and the indicator in the root.

page-links.tsx

TableOfContents

<nav>
PropTypeDefaultDescription
aria-labelstring—Defines a string value that labels the current element. The name of the landmark for screen readers. Default "On this page". Translate it.
valuestring | null—The id of the current heading (controlled). Use with onValueChange.
defaultValuestring | nullnullThe id that is current on the first paint, until the box scrolls or a click (uncontrolled).
onValueChange—Called with the new heading id on scroll and on a link click.
offsetnumber0The height in px of a sticky header over the scroll box (default 0). Give the headings the same scroll-margin-top, so a jump to a hash lands under the header.
rootElement | nullnullThe scroll box that holds the headings, if it is not the page (an element, not a ref).
trackInViewbooleanfalseMarks the links of the sections on screen with data-in-view (default false).
...props<nav> attributes—Every other attribute goes to the <nav>, with a ref.

TableOfContentsTitle

<p>
PropTypeDefaultDescription
...props<p> attributes—Every other attribute goes to the <p>, with a ref.

TableOfContentsList

<ol>
PropTypeDefaultDescription
...props<ol> attributes—Every other attribute goes to the <ol>, with a ref.

TableOfContentsItem

<li>
PropTypeDefaultDescription
...props<li> attributes—Every other attribute goes to the <li>, with a ref.

TableOfContentsLink

<a>
PropTypeDefaultDescription
From Base UIUseRenderBase UI docs
...props<a> attributes—Every other attribute goes to the <a>, with a ref.

TableOfContentsIndicator

<li>
PropTypeDefaultDescription
...props<li> attributes—Every other attribute goes to the <li>, with a ref.
  • Use root for a box that scrolls.
  • Use offset under a sticky header.
  • Use one nested list per heading level.
  • For the steps of a task, use a Stepper.
TabMoves through the links.
EnterGoes to the heading.

It is a nav landmark with nested lists.

The current link has aria-current.

  1. AddedTable of Contents.
Open the release