An install command in npm, pnpm, yarn and bun, with a sliding pill, a copy button and a choice that follows to every block on the page.
An "On this page" list for docs and long reads: an indicator glides to the section you're reading and the rail fills as you go.
Run one command to add the component and its dependencies. It lands in your components folder as source you own.
Import it into any page and pass your headings. It works in the App Router and the Pages Router alike.
Every prop is optional except the items. Offset leaves room for a sticky header, and root follows a scrolling panel.
Colours come from props and Tailwind classes, so it follows your theme without extra configuration.
Links are ordinary anchors, focus moves to the heading you choose, and the current section is marked for screen readers.
Yes, it handles nested headings, and yes, it works with a scrolling container instead of the page.
Customize
Usage
import { TableOfContents } from "@/components/motionkit/table-of-contents";
<aside className="sticky top-24 hidden lg:block">
<TableOfContents
title="On this page"
offset={96}
items={[
{ id: "installation", title: "Installation" },
{ id: "usage", title: "Usage" },
{ id: "props", title: "Props", level: 3 },
{ id: "accessibility", title: "Accessibility" },
]}
/>
</aside>Motion
The exact curves this component runs, plotted with Motion's own maths.
Indicator glides
Scroll or click
Documentation, guides, changelogs, legal pages and long blog posts, usually in a sticky sidebar beside the content.
On scroll, once per frame, it finds the last heading whose top has passed a reading line a set distance down the screen; at the very bottom of the page, the final section wins. The active link's position is measured and a spring moves a bright indicator onto it, while a fainter line fills the rail down to it. Clicking a link scrolls to the heading, moves keyboard focus there and updates the address without adding to the history.
| Prop | Type | Default | Description |
|---|---|---|---|
| items | TocItem[] | — | The headings to list: their id, title and level (2, or 3 to indent). |
| title | string | "On this page" | The list's heading and landmark name. |
| offset | number | 96 | How far down the screen a heading counts as reached, in px. Allow for a sticky header. |
| root | HTMLElement | null | — | A scrolling element to follow instead of the page. |
| accent | string | "#5FAEB4" | Colour of the indicator and the rail. |
How we audit: the WCAG 2.2 animation checklist and respecting reduced motion in React.
Yes. The file starts with "use client", so you can import it straight into a Server Component page or layout. It works in Vite as is, and in Astro as a React island.
Only the motion package, beside React and Tailwind CSS v4. There is no MotionKit package and no Tailwind config to add.
Yes, with MotionKit Plus. Add the @motionkit registry and your personal token to components.json (the snippet is on your account page), then run npx shadcn@latest add @motionkit/table-of-contents. It saves the file to components/motionkit and installs its dependencies.
Table of Contents is part of MotionKit Plus (£12 / $15 / €14 a month or £96 / $120 / €112 a year). The live preview and playground are free to explore; Plus unlocks its source code, every customisation control and commercial use.
With reduced motion on, links jump rather than scroll smoothly and the indicator moves without gliding.
Yes. Pass the panel as root and it measures headings against that element and listens to its scroll instead of the window's.
An install command in npm, pnpm, yarn and bun, with a sliding pill, a copy button and a choice that follows to every block on the page.
A mega-menu with one dropdown that glides and resizes between items, its content sliding in from the side you moved towards.
Accessible tabs with a sliding indicator and soft content transitions.
The live preview is free to explore. Plus unlocks the source for Table of Contents and every other premium component.
Not ready for Plus? A free account unlocks 4 premium components, Depth Card, Rolling Text, Dot Wave and Confetti Button, with no card needed.
Run one command to add the component and its dependencies. It lands in your components folder as source you own.
Import it into any page and pass your headings. It works in the App Router and the Pages Router alike.
Every prop is optional except the items. Offset leaves room for a sticky header, and root follows a scrolling panel.
Colours come from props and Tailwind classes, so it follows your theme without extra configuration.
Links are ordinary anchors, focus moves to the heading you choose, and the current section is marked for screen readers.
Yes, it handles nested headings, and yes, it works with a scrolling container instead of the page.
Customize
Usage
import { TableOfContents } from "@/components/motionkit/table-of-contents";
<aside className="sticky top-24 hidden lg:block">
<TableOfContents
title="On this page"
offset={96}
items={[
{ id: "installation", title: "Installation" },
{ id: "usage", title: "Usage" },
{ id: "props", title: "Props", level: 3 },
{ id: "accessibility", title: "Accessibility" },
]}
/>
</aside>Motion
The exact curves this component runs, plotted with Motion's own maths.
Indicator glides
Scroll or click