FRENVersion française

In-page navigation

Minimap

Minimap

Demo

Loading demo…

A tiny version of the document, pinned to the edge: short lines stand in for headings or lines of text. You see the shape of a long piece of content at a glance and jump into it with one click. On hover, the rail of lines often expands into a table of contents with the real headings.

Story

Did you know

The word comes from video games: the little map in a corner of the screen that shows the whole level and where you are. Code editors took the idea as is, with the file instead of the level and the visible area instead of the player.

Timeline

  1. 2010sSublime Text 2 makes the minimap popular with developers.
  2. 2017VS Code 1.10 adds a minimap to its editor.
  3. 2020sNote-taking tools shrink the table of contents to a rail of lines that expands on hover.

Vocabulary

Names

FR
Minimap, mini-carte, aperçu du document, sommaire flottant, rail de sommaire
EN
Minimap, outline rail, scroll map, document overview, floating table of contents, VS Code minimap

Common uses

  • Code editors: an overview of a long file
  • Note-taking tools and wikis: a page's headings as lines along the edge
  • Dense docs where a full TOC column would take too much room
  • Diffs and logs: spot changed or failing areas at a glance

Often paired with

The components it usually sits with, by page type, in reading order.

Code

<nav aria-label="On this page" class="rail">
  <a href="#install" style="--w: 28px"><span>Installation</span></a>
  <a href="#config" style="--w: 18px"><span>Configuration</span></a>
  <a href="#faq" style="--w: 24px"><span>FAQ</span></a>
</nav>

<script>
  const links = document.querySelectorAll('.rail a')
  const io = new IntersectionObserver((entries) => {
    for (const e of entries) {
      if (!e.isIntersecting) continue
      for (const a of links) {
        if (a.hash === '#' + e.target.id) a.setAttribute('aria-current', 'true')
        else a.removeAttribute('aria-current')
      }
    }
  }, { rootMargin: '0px 0px -70% 0px' })
  document.querySelectorAll('section[id]').forEach((s) => io.observe(s))
</script>

<style>
  .rail { position: fixed; right: 1rem; top: 30%; display: grid; justify-items: end; padding: 6px; border-radius: 8px; }
  .rail a { display: flex; align-items: center; gap: 8px; min-height: 24px; color: inherit; text-decoration: none; }
  .rail a::after { content: ''; width: var(--w); height: 3px; border-radius: 2px; background: currentColor; opacity: 0.4; }
  .rail a[aria-current]::after { opacity: 1; height: 4px; }
  /* Collapsed: the label stays in the DOM (accessible name) but takes no room */
  .rail span { max-width: 0; overflow: hidden; white-space: nowrap; }
  .rail:is(:hover, :focus-within) { background: Canvas; box-shadow: 0 4px 16px rgb(0 0 0 / 0.15); }
  .rail:is(:hover, :focus-within) span { max-width: 12rem; }
</style>

Good to know

  • Two families. The editor minimap (VS Code, Sublime Text) draws the whole content in miniature. The line rail, Notion-style, keeps only the headings. For a web page, the rail is almost always enough.
  • Line widths should mean something: heading level (long h2, short h3) or section length. Random widths only add noise.
  • To show the visible area (the editors' "slider"): height = clientHeight / scrollHeight, position = scrollTop / scrollHeight, as a share of the minimap's height.
  • For a true miniature of the content, draw into a <canvas> rather than cloning the DOM with transform: scale(). A clone doubles the rendering cost and duplicates every id.

Accessibility

Must have

  • Each line is a link containing the section title as text. When collapsed, hide it visually (max-width: 0, overflow: hidden) but keep it in the DOM: it is the accessible name.
  • Expand the rail on :focus-within as well as :hover, so headings also show up for keyboard users.
  • The expanded panel follows WCAG 1.4.13: it stays open while the pointer moves onto it, and Escape dismisses it.

Often forgotten

  • A line is 3 px tall, the target must be at least 24 (WCAG 2.5.8). Enlarge the link, not the line.
  • Active line: aria-current="true", plus a shape change (thicker, longer) on top of colour, with 3:1 contrast (WCAG 1.4.11).
  • A <canvas> minimap duplicates content that is already readable: set aria-hidden="true" so it isn't announced twice.

Nice to have

  • An option to hide the minimap, like VS Code's editor.minimap.enabled setting. It takes up room and draws the eye.
  • No expand animation or smooth scrolling under prefers-reduced-motion: reduce.

Who uses it