Skip to content

Table of Contents

Last updated 27 Oct 2026

NbTableOfContents lists the sections of a long page as links, highlights the section being read as the page scrolls, and scrolls to a section when one is chosen. It comes in two forms: docked, for a page with a gutter beside the content, and floating, a single button that opens the list over a page with no room for one.

Items ​

items is flat, in document order, with each heading's level. The component nests them itself. Nesting is relative, so an h4 straight under an h2 sits one step in, and a skipped level never opens an empty indent.

By default an item's id is the target element's id, and each link points at #id, so a link opened in a new tab lands on the same section. When the targets have no ids (headings an editor rebuilds as they are typed, for example) pass resolveTarget:

vue
<NbTableOfContents
  :items="outline"
  :resolve-target="(item, index) => headings[index] ?? null"
/>

Floating ​

The floating form is for a page with no gutter: a narrow reading column, or a phone. It starts closed as a single button, opens onto a surface over the page, and closes again when a section is chosen or Escape is pressed. Place it yourself, typically in a corner of the page.

vue
<div class="page">
  <article ref="article">…</article>
  <NbTableOfContents
    class="page__contents"
    variant="floating"
    :items="sections"
    :root="article"
  />
</div>

<style scoped>
.page {
  position: relative;
}
.page__contents {
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
}
</style>

Props ​

PropTypeDefaultDescription
itemsITableOfContentsItem[](required)Sections in document order: { id, label, level }.
activestring | nullunboundThe section being read (v-model:active). Unbound, tracked internally.
openbooleanunboundWhether the list shows (v-model:open). Unbound, docked starts open, floating not.
variant'docked' | 'floating''docked'Gutter form, or a button that opens the list over the page.
collapsiblebooleantrueDocked only: whether it can be hidden to its show button.
titlestring'Contents'Visible heading above the list.
labelstring'Table of contents'Accessible name of the <nav> landmark.
showLabelstring'Show contents'Accessible name of the show button.
hideLabelstring'Hide contents'Accessible name of the hide button.
rootHTMLElement | nullnullWhere targets are looked up. null is the whole document.
resolveTarget(item: ITableOfContentsItem, index: number) => HTMLElement | nullby idFinds a section's element when targets have no ids.
spybooleantrueHighlight the section being read as the page scrolls.
offsetnumber96Pixels below the top of the scroll container a heading still counts as current.
updateHashbooleantrueWrite #id to the address bar with replaceState on a choice.
followHashbooleanfalseScroll once to the section in the address bar's fragment when it renders.

Events ​

EventPayloadDescription
navigateitem: ITableOfContentsItemA section was chosen from the list.
update:activeid: string | nullThe current section changed, by scroll or choice.
update:openopen: booleanThe list was shown or hidden.

Exposed methods ​

MemberTypeDescription
go(item: string | ITableOfContentsItem, opts?: { instant?: boolean }) => voidScrolls to a section, as a click on its link does.
measure() => voidRe-reads the scroll position, after moving content yourself.

Tokens used ​

TokenApplied to
--nb-c-text-subtle, --nb-c-textLinks, and the current or hovered link
--nb-c-primaryThe current section's reading-edge rule
--nb-c-focus-ringLink focus outline
--nb-c-surface, --nb-c-border, --nb-c-scrimFloating surface (overlay layer) and shadow
--nb-toc-max-heightHeight after which the list scrolls
--nb-toc-floating-widthWidth of the floating surface (18rem)