Skip to content

Article table of contents with reading progress

A sticky sidebar table of contents for blog posts: it highlights the section being read, shows the reading time left and folds into a list under the title on mobile.

  • Tailwind
  • React
  • CSS
  • WordPress
Open in a new tab

Description

On a long article, readers always know where they are. On large screens the table of contents stays stuck beside the text: the current section is highlighted and marked with aria-current="location", past sections get a check mark, and a progress bar goes with the time left (“3 min left”, then “Article finished”). That time is not a global estimate: the script counts the words of each section, at 200 words per minute adjustable with data-nsap-pace, so a dense section weighs more than a short one. Below 960 px the table of contents becomes a folded list right under the title, with the current section and the time left in a small bar that stays visible; the list opens over the text without moving it. ARIA disclosure pattern with details and summary: Tab to move through, Enter or Space to open, Escape to close and return to the control; the list also closes on an outside click, when focus leaves it and when a section is chosen. Focus follows the jump to the heading and is never hidden under the bar. Nothing is announced while scrolling: progress can be read on demand through the progressbar role. Without JavaScript the list of anchor links stays complete and working, with the total duration. With prefers-reduced-motion the jump is immediate and nothing animates. Sizes in rem, 44 px targets, AA contrast in light and dark mode, colours via variables, an offset adjustable with --nsap-top if your site already has a sticky header, no dependencies.

Code

Loading the code…

The code of this component in

Archive contents

navigation-sommaire-article-progression-html-tailwind.zip3 files · 11 Ko

  • index.html30 Ko
  • README.md5 Ko
  • LICENSE.md1 Ko

Tags

Updated on December 2, 2026.

Reviews

No reviews yet.

In the same spirit

  • A slim bar at the top of the page with a message, a link and a close button; once closed, it stays hidden for the period you choose.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A column of dots on the side of the page that follows the section being read and lets visitors jump to it, with a label on hover and focus.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • An order step indicator: finished steps clickable to go back, the current step announced, upcoming steps locked.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Tooltips in four positions that open on hover, tap and keyboard focus, and close with Escape, as WCAG requires.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component