Outline builds a table of contents from the headings of any article and keeps it in sync as the reader scrolls. The current section highlights itself, and an optional progress bar shows how far through the page they are. One JavaScript file, one stylesheet, no dependencies, no jQuery, no build step and no external requests.
Drop one empty element above your content and point it at the article. Outline reads the H2 and H3 headings, nests the sub-headings, generates ids for headings that do not have one, and handles the rest: sticky positioning, scroll spy, smooth scrolling with an offset for sticky headers, and a collapsible list on mobile.
Why a table of contents
Long pages lose readers in the first screen. A visible list of sections tells them what is here before they commit, and a highlight that follows the scroll tells them where they are. That is the difference between a page someone skims and a page someone reads.
Accessible by default
The list is a real ordered list of links, navigable with the keyboard and announced as a list. The current entry carries aria-current, the progress bar is a real progressbar with a live aria-valuenow, entries have a visible focus ring, and smooth scrolling is skipped for visitors who ask for reduced motion.
Works anywhere
Static HTML, WordPress, Shopify, Webflow, Framer, React, Vue, Svelte, Astro. If the page has headings and one container, it works. Setup is a data attribute; options can be a JSON object in that attribute or passed to the constructor.
Builder included
The demo page is a real long-form article and also a builder: change the heading levels, the scroll offset, numbering, mobile collapse and smooth scrolling, watch the list rebuild, and copy the embed snippet.
Honest limits
It builds from the headings in the page, it does not read your CMS. It uses the ids your headings already have and only generates them when they are missing. It does not add anchor buttons to headings. The scroll spy listens to scroll and resize, so a page with thousands of headings will cost more than a page with twelve.
Features
Nested list from H2 and H3 headings, or H2 only
Highlights the current section as the reader scrolls, with aria-current
Reading progress bar measured against the article
Smooth scrolling with an offset for sticky headers
Collapses into a native details element on small screens
Generates clean ids for headings that have none, never duplicating one
Optional numbering and a configurable active class
outline:change event and a public API: refresh, destroy, Outline.autoInit
No dependencies, no build step, no external requests
You have to login to leave a review!
All Reviews
No Review!
What type of support is included? Verified source code Free support included Download code immediately Quality guarantee for your satisfaction Support: info@sellanycode.com
You have to purchase this item to get support!
You have to login to ask a question!
All Questions
No Question!
$20
Verified source code
Join 36136+ buyers which trust us!
Download code immediately
100% Guarantee For Item! Satisfaction guarantee policy.