Outline
An "On this page" list of the headings of one long page, with an ink line that follows the section in view. The list on the right of this page is one.
Usage
Use it when
- A long page with four or more sections people jump between: documentation, a syllabus, course rules, a long report.
- Wide screens with room for a third column beside the content.
Use something else when
- Moving between pages of the app: use App shell.
- A list of sections that each replace the content: use Sidebar.
- Sibling sections where only one shows at a time: use Tabs.
- A short page with two or three sections: use Sections. Let the headings do the work.
Where it goes. A sticky column to the right of the content on wide screens (about 200 to 220 px), starting level with the page title. Hide it below about 1100 px; on phones the page headings are enough, or put the same links at the top of the page.
Examples
Introduction
Database Systems covers relational design, SQL, transactions and indexing over fourteen weeks.
Grading
Assignments 40 %, midterm 25 %, final project 35 %. Late work loses 10 % per day.
Office hours
Tuesdays 13:00 to 15:00 in room H 2.14, or by appointment.
Policies
Work alone on assignments unless the brief says otherwise.
<nav class="toc" data-lds-toc aria-label="On this page"> <span class="toc__ink" aria-hidden="true"></span> <a href="#intro">Introduction</a> <a href="#grading">Grading</a> <a href="#office-hours">Office hours</a> </nav> <!-- later in the page --> <h2 id="intro">Introduction</h2> …
<nav class="toc" aria-label="On this page" style="width: 200px;"> <a href="#ol2" aria-current="true">Usage</a> <a href="#ol2">Examples</a> <a href="#ol2">Accessibility</a> </nav>
Anatomy
| Part | What it is |
|---|---|
nav.toc[data-lds-toc] | Required. The list with aria-label="On this page"; a 1.5 px rail on its left. |
.toc__ink | The 1.5 px strong line on the rail that slides to the current link; first child, aria-hidden. |
a[href="#id"] | Required. One link per section heading id. aria-current="true" marks the section in view. |
States
| State | How |
|---|---|
aria-current="true" | Strong text at weight 500; the ink sits beside it. |
hover | Text darkens to strong over --d-fast. |
Motion and microinteractions
- Ink: translates and resizes to the current link on
--spring-smoothover--d-smooth(560 ms), so a fast scroll through several sections reads as one glide. - Only one thing moves; the links change color, they do not slide or scale.
- Reduced motion: the ink moves in 120 ms linear. Use
scroll-behavior: smoothon the page only underprefers-reduced-motion: no-preference.
Accessibility
<nav aria-label="On this page">with plain links to heading ids, in document order.aria-current="true"(notpage) marks the section in view, because the page itself does not change.- Give headings a
scroll-margin-topequal to any sticky header so a jump does not hide the heading.
Do and don't
Do
- Link only the
<h2>level, or<h2>and<h3>at most. - Use the exact heading text as the link text.
Don't
- Use the outline as the main navigation.
- Show it on phones as a fixed column; it steals the width the text needs.
Behavior and code
Plain HTML. data-lds-toc on .toc watches the elements its a[href^="#"] links point to (looked up by id in the document) with an IntersectionObserver whose bottom margin is -60 % of the window, marks the topmost visible section with aria-current="true", and moves and sizes .toc__ink. It marks the first section on init.