Skip to content

Props

TableOfContents accepts the following props.

PropTypeDefaultDescription
tocToc | nullnullPrefetched TOC (page.body.toc). When set, no auto-fetch.
pathstring''Content path for auto-fetch. Defaults to current route path.
collectionstring''Content v3 collection. Falls back to nuxtToc.collection or 'content'. Ignored on v2.
depthnumbermodule nuxtToc.depth (default 2)Max link-tree depth: 1 = top-level only, 2 = one nested level, 3+ = deeper.
isSublistShownbooleantrueWhen false, forces effective depth to 1 (legacy API).
isTitleShownWithNoContentbooleanfalseStill show title when there are no links.
titlestring'Table of Contents'Heading text.
scrollSpybooleanmodule trueEnable IntersectionObserver active highlighting.
rootMarginstringmodule valueObserver rootMargin (sticky header tuning).
smoothbooleanmodule falseSmooth-scroll on TOC link click.
scrollOffsetnumbermodule 0Pixel offset when scrolling to headings.

Examples

Depth control

vue
<!-- Top-level headings only -->
<TableOfContents :toc="page.body?.toc" :depth="1" />

<!-- Default: top + one nested level -->
<TableOfContents :toc="page.body?.toc" :depth="2" />

<!-- Deeper trees when Content TOC includes h4+ -->
<TableOfContents :toc="page.body?.toc" :depth="3" />

Custom title, no nested items

vue
<TableOfContents :toc="page.body?.toc" title="On this page" :depth="1" />
<!-- or legacy: :is-sublist-shown="false" -->

Auto-fetch a fixed path (v3)

vue
<TableOfContents path="/docs/intro" collection="docs" title="Contents" />

Empty TOC still shows title

vue
<TableOfContents :toc="{ links: [] }" title="Outline" :is-title-shown-with-no-content="true" />

Released under the MIT License.