Home

Table of Contents Tree

Usage

The TOC tree is the right-sidebar list of headings with scroll-spy highlighting. Start with:

  • --toc-item-* tokens for typography, spacing, and colors

  • --toc-indent to control nesting

  • --toc-border-* tokens for the left rule emphasis

  • --toc-sticky-top and --toc-max-height for sticky behavior

Tokens

Title Tokens

TokenDescriptionDefault Value
--toc-font-familyTOC font familyvar(--layout-font-family)
--toc-title-font-sizeTitle font sizevar(--font-size-xs)
--toc-title-font-weightTitle font weightvar(--font-weight-extralight)
--toc-title-colorTitle text colorvar(--text-color-secondary)
--toc-title-gapGap between icon and textvar(--space-2)
--toc-title-margin-bottomSpace below titlevar(--space-3)
--toc-title-iconTitle icon contentnone
--toc-title-icon-sizeTitle icon sizevar(--font-size-xs)

Item Tokens

TokenDescriptionDefault Value
--toc-item-font-sizeItem font sizevar(--font-size-sm)
--toc-item-line-heightItem line heightvar(--line-height-snug)
--toc-item-padding-yItem vertical paddingvar(--space-1)
--toc-item-padding-xItem horizontal paddingvar(--space-1)
--toc-item-colorItem text colorvar(--text-color-secondary)
--toc-item-color-hoverHover item colorvar(--text-color-primary)
--toc-item-color-activeActive item colorvar(--color-accent)
--toc-item-color-mutedMuted color for deep levelsvar(--text-color-muted)

Layout Tokens

TokenDescriptionDefault Value
--toc-indentIndent per heading levelvar(--space-4)
--toc-sticky-topSticky offset from topvar(--space-4)
--toc-max-heightMaximum height when stickycalc(100vh - var(--toc-sticky-top) * 2)

Border Tokens

TokenDescriptionDefault Value
--toc-border-widthBase border widthvar(--border-width-default)
--toc-border-width-emphasisBorder width on hover/activevar(--border-width-thick)
--toc-border-colorBase border colorvar(--border-color-muted)
--toc-border-color-hoverHover border colorvar(--border-color-default)
--toc-border-color-activeActive border colorvar(--toc-item-color-active)

Examples

Compact Sidebar TOC

Tighter typography and smaller indents:

:root {
  --toc-item-font-size: var(--font-size-xs);
  --toc-item-padding-y: 2px;
  --toc-indent: var(--space-3);
}

Emphasized Active Heading

Make the active heading easy to spot:

:root {
  --toc-border-width-emphasis: 3px;
  --toc-border-color-active: var(--color-accent);
  --toc-item-color-active: var(--text-color-primary);
}

Tips

Sticky behavior: Set --toc-sticky-top: 0 to disable sticky positioning (it becomes static on smaller screens automatically).

Deep level clarity: Adjust --toc-item-color-muted to keep deeper levels readable without overpowering top levels.

Title icon: Use --toc-title-icon to add a lightweight marker (e.g. a unicode string).

© 2026 Stencila