Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

TableOfContents

A controlled outline of a long document.

Preview

Live preview

Changes apply to this preview only.

Width adapts to the available space

More examples

Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.

Guide outline

Every outline entry points to an actual heading in this isolated document.

Open preview

Nested article outline

Every outline entry points to an actual heading in this isolated document.

Open preview

Controlled active heading

Every outline entry points to an actual heading in this isolated document.

Open preview

Usage

Supply stable heading ids and update activeId from your own navigation or scroll tracking.

API reference

Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.

PimoluTableOfContentsItem

Type source
PimoluTableOfContentsItem public API
NameTypeDefaultDescription
idRequiredstring—Id of the heading the entry points to.
labelRequiredReactNode—Visible entry label.
levelPimoluTableOfContentsLevel | undefined2Nesting level. Level 3 entries are nested inside the preceding level 2 entry. Defaults to 2.
idRequired

string

No default extracted.

Id of the heading the entry points to.

labelRequired

ReactNode

No default extracted.

Visible entry label.

level

PimoluTableOfContentsLevel | undefined

Default: 2

Nesting level. Level 3 entries are nested inside the preceding level 2 entry. Defaults to 2.

PimoluTableOfContentsProps

Type source
PimoluTableOfContentsProps public API
NameTypeDefaultDescription
itemsRequiredPimoluTableOfContentsItem[]—Public Pimolu prop; see the source declaration for details.
activeIdstring | undefined—Id of the entry that matches the heading in view.
titleReactNode"On this page"Visible title of the navigation. Defaults to "On this page".
onNavigate((item: PimoluTableOfContentsItem) => void) | undefined—Called with the entry when one of its links is activated.
classNamestring | undefined—Public Pimolu prop; see the source declaration for details.
onChangeChangeEventHandler<HTMLElement, Element> | undefined—Standard React/HTML attribute.
defaultValuestring | number | readonly string[] | undefined—Standard React/HTML attribute.
styleCSSProperties | undefined—Standard React/HTML attribute.
aria-labelstring | undefined—Defines a string value that labels the current element.
childrenReactNode—Standard React/HTML attribute.
onClickMouseEventHandler<HTMLElement> | undefined—Standard React/HTML attribute.
itemsRequired

PimoluTableOfContentsItem[]

No default extracted.

Public Pimolu prop; see the source declaration for details.

activeId

string | undefined

No default extracted.

Id of the entry that matches the heading in view.

title

ReactNode

Default: "On this page"

Visible title of the navigation. Defaults to "On this page".

onNavigate

((item: PimoluTableOfContentsItem) => void) | undefined

No default extracted.

Called with the entry when one of its links is activated.

className

string | undefined

No default extracted.

Public Pimolu prop; see the source declaration for details.

onChange

ChangeEventHandler<HTMLElement, Element> | undefined

No default extracted.

Standard React/HTML attribute.

defaultValue

string | number | readonly string[] | undefined

No default extracted.

Standard React/HTML attribute.

style

CSSProperties | undefined

No default extracted.

Standard React/HTML attribute.

aria-label

string | undefined

No default extracted.

Defines a string value that labels the current element.

children

ReactNode

No default extracted.

Standard React/HTML attribute.

onClick

MouseEventHandler<HTMLElement> | undefined

No default extracted.

Standard React/HTML attribute.

Accessibility

  • Every link must reach a real heading; distinguish the current location without color alone.
Read the accessibility guide →