Table of Contents
Table of Contents (Left Side Navigation)
Sticky left-hand TOC navigation with automatic scroll-spy, progress indicator, and section filter.
headings- Array of TOCHeading objects ({ id, title, level }) defining the document outline.
showProgress- Displays an animated top progress bar reflecting current document scroll percentage.
showSearch- Enables an inline search filter input inside the right-hand TOC sidebar.
Installation
New project? Follow the installation guide to set up Tailwind CSS, shadcn, the cn helper and lucide-react, register the @algorize-ui registry once, then copy your styles from the Themes page.
Install Table Of Contents
components/ is written into your project. Copy any snippet from a Usage tab above and it runs.
Install dependencies
Step 1 installs these for you. Run them yourself only if you are adding Table Of Contents to an existing project by hand. The cn helper and lucide-react are not listed — the installation guide covers them once for every component. shiki comes in with the component above rather than from Table Of Contents directly.
ui-codeblocks is a component, not a package — the shadcn CLI installs it as source files.
shiki is an npm package.
Features
Right-Side Sticky Panel
Positions the TOC navigation cleanly on the right column while main content flows on the left.
Scroll-Spy Tracking
Automatically detects active viewport headings and animates the active indicator smoothly along a spring curve, with no animation library.
Section Search Filter
Filter long document section headers instantly with an embedded search input.
Mobile Dropdown Menu
Collapses into a sticky mobile bar with drawer navigation on smaller devices.
Props Reference
| Component / Object | Prop | Type | Default | Description |
|---|---|---|---|---|
TableOfContentsBlock | items | TOCItem[] | DEFAULT_ITEMS | Array of section content blocks with titles, levels, descriptions, and optional code snippets. |
TableOfContentsBlock | headings | TOCHeading[] | Derived from items | Custom outline structure containing id, title, and level (1 | 2 | 3). |
TableOfContentsBlock | activeId | string | Controlled by scroll-spy | Manually override the currently highlighted active section ID. |
TableOfContentsBlock | onSelectHeading | (id: string) => void | Smooth scroll to target | Callback fired when a user clicks on a section heading in the TOC sidebar. |
TableOfContentsBlock | color | string | "var(--primary)" | Accent theme color for active indicator, progress bar, and search highlights (Hex, RGB, or CSS var). |
TableOfContentsBlock | showProgress | boolean | true | Shows or hides the top reading progress indicator bar. |
TableOfContentsBlock | showSearch | boolean | true | Shows or hides the inline section search filter input inside the sidebar. |
TableOfContentsBlock | sidebarTitle | string | "On this page" | Header text displayed at the top of the sticky TOC sidebar. |
TOCItem / TOCHeading | id | string | Required | Unique DOM element ID matching the section heading target. |
TOCItem / TOCHeading | title | string | Required | Display title shown in the TOC sidebar and main content section. |
TOCItem / TOCHeading | level | 1 | 2 | 3 | 1 | Indentation hierarchy level for sub-sections. |
TOCItem | description | string | — | Body paragraph content associated with the section. |
TOCItem | codeSnippet | string | — | Code snippet displayed inside the section card with a copy-to-clipboard button. |
TOCItem | badge | string | — | Badge label shown next to the section title (e.g., "New", "Updated"). |