---
title: "Track Contents"
description: "The headings of a long page on one track that bends with each level. The part you read is solid, and a dot moves to the current heading."
url: https://gelatinui.com/components/track-contents
markdown_url: https://gelatinui.com/components/track-contents.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/track-contents"
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Track Contents

> The headings of a long page on one track that bends with each level. The part you read is solid, and a dot moves to the current heading.

Page: https://gelatinui.com/components/track-contents

## When to use it

Best for: The headings of a long article on one bent track that shows what you read and where you are.

- Put a `TrackContentsTrack` last in the outer `TrackContentsList`.
- Nest a `TrackContentsList` in an item for sub-headings: the track bends in.
- Set `nodes` to show a dot for each heading.

## When not to use it

- For a plain list of headings with no track, use [Table of Contents](https://gelatinui.com/components/table-of-contents.md).
- For section marks with no text, use a [Preview Rail](https://gelatinui.com/components/preview-rail.md).

## Notes for agents

- It is built on Table of Contents: the same `nav`, links, tracking, and props.
- Pass `root` when the article scrolls in a box, not the page.
- Keep `TrackContentsTitle` equal to the root `aria-label`.
- A long list: give the root a max height and `overflow-y-auto`; the list keeps the dot in view.

## Anatomy

```text
TrackContents
├─ TrackContentsTitle (0..n)
├─ TrackContentsList (0..n)
├─ TrackContentsItem (0..n)
├─ TrackContentsLink (0..n)
└─ TrackContentsTrack (0..n)
```

## API reference

### TrackContents

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. The name of the landmark for screen readers. Default "On this page". Translate it. |
| `value` | `string \| null` |  | The id of the current heading (controlled). Use with `onValueChange`. |
| `defaultValue` | `string \| null` |  | The id that is current on the first paint, until the box scrolls or a click (uncontrolled). |
| `onValueChange` | `function` |  | Called with the new heading id on scroll and on a link click. |
| `offset` | `number` |  | The 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. |
| `root` | `Element \| null` |  | The scroll box that holds the headings, if it is not the page (an element, not a ref). |
| `nodes` | `boolean` | false | Draws a 5px dot on the track for each heading: hollow ahead, faint when read, full in view. |

### TrackContentsTitle

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### TrackContentsList

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### TrackContentsItem

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### TrackContentsLink

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` |  | The id of the heading. Default: the `href` without `#`. Set it when `render` mounts a router link that builds its own `href` (`render={<Link to="/docs" hash="install" />}`). |

Also takes every prop of Base UI `UseRender`: https://base-ui.com/react/components/use-render

### TrackContentsTrack

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| TrackContents | `track-contents` |  |  |  |
| TrackContentsTitle | `track-contents-title` |  |  |  |
| TrackContentsList | `track-contents-list` | `data-depth` |  |  |
| TrackContentsItem | `track-contents-item` |  |  |  |
| TrackContentsLink | `track-contents-link` | `data-in-view` |  |  |
| TrackContentsTrack | `track-contents-track` | `data-dot`, `data-range`, `data-state` | `--track-dot`, `--track-range-bottom`, `--track-range-top` |  |

## Usage

Put the links in nested lists, and the track last in the outer list.

```tsx title="docs-contents.tsx"
import {
  TrackContents,
  TrackContentsItem,
  TrackContentsLink,
  TrackContentsList,
  TrackContentsTitle,
  TrackContentsTrack,
} from "@/components/pro/navigation/track-contents";

export function DocsContents() {
  return (
    <TrackContents aria-label="On this page">
      <TrackContentsTitle>On this page</TrackContentsTitle>
      <TrackContentsList>
        <TrackContentsItem>
          <TrackContentsLink href="#install">Install</TrackContentsLink>
        </TrackContentsItem>
        <TrackContentsItem>
          <TrackContentsLink href="#configure">Configure</TrackContentsLink>
        </TrackContentsItem>
        <TrackContentsTrack />
      </TrackContentsList>
    </TrackContents>
  );
}
```

## Compose

Rules:

- Touch targets (`touch-targets`): Give every control a hit area of at least 44 px on touch screens, even when it looks smaller.
- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/track-contents
```

It adds 17 registry items: 16 files, 3369 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@xstate/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Table of Contents](https://gelatinui.com/components/table-of-contents.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Table of Contents](https://gelatinui.com/components/table-of-contents.md)
- [Preview Rail](https://gelatinui.com/components/preview-rail.md)
- [Scroll Area](https://gelatinui.com/components/scroll-area.md)
- [Anchor](https://gelatinui.com/components/anchor.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves to the next heading link. |
| Enter | Goes to the heading. |

## Motion

| Part | Motion |
| --- | --- |
| Range and dot | glide · the range and the dot move along the track to the headings in view |
