Skip to content
Menus & Navigation

Table Of Contents

Scrollspy on-this-page nav with an animated active indicator.

Import

tsx
import { TableOfContents } from "@cronus-ui/ui";
bash
npx cronus-ui add table-of-contents

Examples

.cronus

The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.

PortedParity: MatchGeometry 1/1Pixel diff 0 pxLogic 1/1Parity scoreboard
default.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component TableOfContentsDefault layout:inline style:table-of-contents {
  aria-label:"On this page"
  label "On this page"
  text "Overview"
  text "Usage"
}

page "/audit/table-of-contents/default" type:custom {
  use TableOfContentsDefault
}

API Reference

Generated from the component's exported types.

TableOfContentsProps

Extends Omit<HTMLAttributes<HTMLElement>, "children">

Skip TableOfContentsProps props table
PropTypeDefaultDescription
items
TableOfContentsItem[]—The entries to render, in document order. When omitted, headings are auto-discovered from the DOM via .
selector
stringDEFAULT_SELECTORCSS selector used to auto-discover headings when is omitted. Only elements with an `id` participate; depth is derived from the heading level (the shallowest level found becomes depth 0). Defaults to `"h2, h3"`.
containerId
string—`id` of the element that scopes heading discovery. When that element is itself a scroll container (`overflow-y: auto | scroll`), it also becomes the scrollspy root and the target of click-to-scroll — otherwise the window scrolls. Defaults to the whole document.
offset
number0Pixels between the top of the scroll root and the activation line — match your sticky-header height. Also subtracted when scrolling to a section on click. Defaults to `0`.
className
string—Additional class names merged onto the root.
id
string—DOM id of the root element.