v0.3.1 StableFoundation ComponentReact 18 & 19Zero Runtime CSS

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:

PropTypeDefaultDescription
items{id,label,level?}[]requiredSection anchors and optional visual nesting.
labelstringOn this pageNavigation 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-contents

Make 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.

TableOfContents.tsxREACT / TSX

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.