Skip to main content

Table of Contents

A contents list built from the page's headings, with scrollspy, sticky positioning and collapsible sections.

The block renders through the toc element — the same PHP that runs in the page builder, so the front end is identical either way.

What the sidebar exposes

OptionWhat it does
titleHeading above the list
levelsWhich heading levels to collect
hierarchicalNest sub-headings
min_headingsDo not render below this many headings
numerationNumber the entries
numeration_suffixWhat follows each number
collapsibleLet visitors collapse it
collapsed_defaultStart collapsed
label_showText for the expand control
label_hideText for the collapse control
scopeWhich part of the page to scan
scope_selectorA custom selector for that scope
smooth_scrollAnimate the jump
scroll_offsetOffset for a fixed header
scrollspyHighlight the section being read
nofollowMark the links nofollow
noindexKeep the list out of search results
widthHow wide the list runs
custom_widthA specific width
floatFloat it beside the content
stickyKeep it visible while scrolling
sticky_offsetOffset when stuck
title_sizeTitle size
items_sizeEntry size
bg_colorBackground
border_colorBorder
title_colorTitle colour

Anything not listed stays available in the page builder, and round-trips untouched — the block only writes the values you change, so an element styled in the builder keeps every setting this sidebar does not show.

This is the one block whose preview cannot be accurate

A table of contents is built from the headings of the page it sits on — and in the block editor those headings live in other blocks, which the server does not see while rendering this one.

So the canvas shows the element's own placeholder rather than a list that would be wrong. Preview the page to see the real contents. Everything else about the block — styling, position, options — previews normally.

note
levels is a checkbox list

It is a checkboxes option. Collecting h2 and h3 is the usual answer; collecting everything down to h6 produces a contents list longer than some of the sections it indexes.

note
Set scroll_offset if the theme has a fixed header

Without it, jumping to a heading puts that heading underneath the header. It is the most common complaint about any in-page jump link.

Margin and padding come from Gutenberg

The block declares core spacing support, so the element's own spacing option is not exposed here — use the Dimensions panel at the top of the sidebar.