Navigation
StickyTOC
Table of contents that sticks while scrolling and highlights the active section via IntersectionObserver.
Quick Preview
Scroll down through this page โ the TOC on the left tracks the active section in real time.
Introduction
Installation
Basic Usage
Variants
Accessibility
Installation
// Copy fromsrc/components/navigation/StickyTOC.tsx
Usage
import StickyTOC from '@/components/navigation/StickyTOC'const tocItems = [{ id: 'intro', label: 'Introduction' },{ id: 'usage', label: 'Basic Usage' },{ id: 'props', label: 'Props' },]// Each section must have a matching id and scroll-mt to clear the navbarexport default function DocsPage() {return (<div className="flex gap-10"><StickyTOC items={tocItems} title="On this page" /><main><section id="intro" className="scroll-mt-24">...</section><section id="usage" className="scroll-mt-24">...</section><section id="props" className="scroll-mt-24">...</section></main></div>)}
Prompt Preview
Copy a prompt that recreates this UI
Paste this into your AI coding assistant to generate code that closely matches the reference, including color, size, shape, typography, spacing, and polish.
Copy-ready AI prompt
Starts from the current visual reference and project constraints.
Tweak only product-specific copy or data after the first generation pass.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items* | TocItem[] | - | Array of {id, label, level?} |
title | string | 'On This Page' | Heading above the list |