Table Of Contents

A sticky React table of contents that reads h2 and h3 headings, marks the section in view with a sliding accent bar as you scroll, and smooth scrolls to a heading on click.

src/registry/ui/table-of-contents.tsx/r/table-of-contents.json

Installation#

bash
npx shadcn@latest add @minidev/table-of-contents

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/table-of-contents.json

Usage#

tsx
import { TableOfContents } from "@/components/ui/table-of-contents"

export function Example() {
  return <TableOfContents />
}

API reference#

TableOfContents props
PropTypeDefault
itemsTocItem[]-
selectorstring-
titlestring"On this page"
offsetnumber24
onActiveChange(id: string) => void-
stickybooleantrue
classNamestring-

Dependencies#

npm

motion

Built from

No other MiniDev files
All navigation components