Skip to content

Sidebar TOC: bold/highlight the current section while scrolling #545

@juanmaguitar

Description

@juanmaguitar

What

On pages that include a sidebar table-of-contents / in-page navigation (list of headings), it would be helpful to visually highlight the currently active section as the reader scrolls.

Why

On long pages it’s difficult to tell where you are in the document. A clear active state improves navigation and readability.

Expected behavior

  • As the user scrolls, the sidebar item corresponding to the heading currently in view becomes bold (or otherwise clearly “active”).
  • The active state updates as the user enters the next/previous section.
  • Clicking a TOC item should also set the correct active state.

Actual behavior

  • Sidebar items don’t clearly indicate the current section while scrolling in the Table of Contents located in the sidebar.

Suggested implementation

Add scrollspy behavior (IntersectionObserver) to toggle an active class based on headings in view.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions