TableOfContents
Link to sections and identify the visible location.
Interactive preview
Overview
Native links make navigation predictable.
Usage
Keep section ids stable across renders.
Usage
import { TableOfContents } from "@devvy-ui/react";
<TableOfContents items={[{id:'overview',label:'Overview'},{id:'usage',label:'Usage'}]} />API reference
Native HTML attributes, className, style and a forwarded ref are supported. Component-specific props:
| Prop | Type | Default | Description |
|---|---|---|---|
| items | {id,label,level?}[] | required | Section anchors and optional visual nesting. |
| label | string | On this page | Navigation name. |
Accessibility & behavior
Platform Behavior & Guidelines
Native hash links work without observer support. IntersectionObserver enhances the active location; section ids must already exist in the document.
Source ownership
Run npx @devvy-ui/cli init once in your React project, then add the source:
npx @devvy-ui/cli add table-of-contentsMake the source yours.
Start from the canonical implementation used by the package and registry. Change the code, keep the MIT notice, and build the behavior your project needs.
Edit your own copy. Downloaded source uses your changes; the component preview above uses the shipped version. Run the source installer first to include shared helpers.