Toc

Table of contents nav with anchor links indented by heading level and a highlighted active item. Pair it with scroll tracking for docs and long articles.

src/registry/ui/toc.tsx/r/toc.json

Installation#

bash
npx shadcn@latest add @minidev/toc

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/toc.json

Usage#

tsx
import { Toc } from "@/components/ui/toc"

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

API reference#

Toc props
PropTypeDefault
itemsTocItem[]SAMPLE_ITEMS
activeIdstring-
classNamestring-
All navigation components