Components / Page pieces (landing pages, portfolios, docs)
TableOfContents
In-page jump links that highlight the section in view (scroll spy), like the "On this page" list in docs.
import { TableOfContents } from "@stylhero/ui";
Example
Code
import { TableOfContents } from "@stylhero/ui";
function TableOfContentsExample() {
return <TableOfContents label="On this page" items={[{ id: "example", label: "Example" }, { id: "props", label: "Props" }, { id: "keyboard", label: "Keyboard" }]} />;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items required |
TocItem[] |
- | Sections on the page, by element id. |
label |
string |
"On this page" |
Also takes the HTML attributes of its root element (id, style, data-*, aria-*, event handlers…).
Types
type TocItem = { id: string; label: ReactNode };
Accessibility
- A labelled
<nav>that marks the section in view witharia-current.
Generated from src/components/TableOfContents.tsx. Something wrong or missing? Open an issue.