Examples
Examples
Live Example
This documentation page itself uses a live Table of Contents instance. Look for the “CONTENTS” button in the sidebar — it is a real ion-tableofcontents rendering configured with StickyTop enabled. Click the button to expand the dropdown and see how it lists the titled Grid sections on this page (Examples, Usage Notes, Control Properties). As you scroll, the active section is highlighted via scroll-spy.
Default Configuration
The default configuration places the TOC in the sidebar subgrid with StickyTop=1 so it remains visible while the user scrolls. No ScopeToHeading or ScopeToSelector values are set, so it discovers all headings on the page.
Scoped to Specific Headings
To limit the TOC to only h2 and h3 elements, set the ScopeToHeading checklist to include those levels. Combined with ScopeToSelector set to a container CSS selector (e.g. .content-area), the TOC will only index headings within that container, ignoring sidebar or header headings.
Non-Sticky Configuration
When StickyTop is unchecked, the TOC scrolls with the page content. This is useful when the TOC is placed inside a grid section rather than a fixed sidebar, or when the page is short enough that sticky behaviour is unnecessary.
Usage Notes
Notes
- The TOC is built client-side using the bootstrap-toc library. It loads jQuery 3.7.1, the bootstrap-toc CSS, and bootstrap-toc JS into the page via the
HeadTopandBodyBottomsections. - The TOC discovers headings on the page after DOM ready. It uses
Toc.init()to build the navigation and$("body").scrollspy()to highlight the currently visible section. - When ScopeToSelector is set (e.g.
#main-content), the TOC only indexes headings inside that element. When ScopeToHeading is also set, both are combined so the TOC indexes only the selected heading levels inside the selected container. - Grid sections with HideFromTOC enabled will not generate headings that the TOC can discover. Use this to exclude utility sections like sidebars or footers.
- The TOCTitle parameter on a Grid rendering allows you to override the heading text that appears in the TOC. If not set, the TOC uses the visible heading text.
- The TOC renders as a Bootstrap
dropdownwithdata-bs-auto-close="false"so it stays open once the user expands it (thekeep-openclass). - In Experience Editor the TOC does not initialise (guarded by
:not(.scEnabledChrome)) to avoid interfering with the editing experience. - Only one TOC instance should be placed per page. If multiple exist, only the first
#tocelement will be initialised by the library.
Control Properties
Table of Contents
The Table of Contents (TOC) component generates an auto-populated, collapsible navigation menu from the heading structure on the current page. It uses the bootstrap-toc library to discover headings, build a nested list of links, and provide scroll-spy highlighting as the user scrolls through the page.
The TOC renders as a Bootstrap dropdown button labelled “CONTENTS” with expand/collapse behaviour. It can be scoped to specific heading levels or restricted to a CSS selector, and optionally sticks to the top of its container as the user scrolls. Grid sections with HideFromTOC enabled are excluded from the generated list.
Control Properties
| Parameter | Type | Description |
|---|---|---|
| ScopeToHeading | Checklist | Limits which heading levels (h1–h6) the TOC indexes. When empty, all headings are included. Select specific levels to filter — for example selecting only h2 and h3 will ignore h4+ headings. |
| ScopeToSelector | Single-Line Text | A CSS selector that restricts heading discovery to a specific DOM container. For example, #main-content or .article-body. When combined with ScopeToHeading, only matched heading levels inside the selected container are indexed. |
| StickyTop | Checkbox | When checked, adds the sticky-top CSS class so the TOC remains fixed at the top of its container while the user scrolls. |
| Small | Droplink | Column width class at the small breakpoint (inherited from column parameters). |
| Medium | Droplink | Column width class at the medium breakpoint. |
| Large | Droplink | Column width class at the large breakpoint. |
| AddClass | Single-Line Text | Additional CSS class(es) appended to the component wrapper. |