Skip to content
animorio
IT
All components

Collapsing breadcrumbs

Navigation, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 8.7 KBGSAP 28 KBFreeDownload the zip

The breadcrumbs of Lumen, a made-up documentation site, on white with a single blue accent: opening a folder slides the new level in from the right and the others along; once the path is longer than four levels the middle ones squeeze, fade and gather into a «…» pill that opens a small cascading menu. Clicking a level shortens the path, and a grey pill slides behind the crumb under the pointer. Minimal style.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Collapsing breadcrumbs" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Collapsing breadcrumbs</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the breadcrumbs of a made-up docs site, Lumen: the path grows as you open a folder, the middle levels fold
         into a «…» pill when it no longer fits, the pill opens a small menu of the hidden levels, and a click on any
         level walks the path back -->
    <section class="doc" data-doc aria-label="Lumen documentation">
      <header class="bar">
        <span class="brand">
          <svg class="brand__mark" viewBox="0 0 20 20" aria-hidden="true"><path d="M4 3.5h7.5a4.5 4.5 0 0 1 4.5 4.5v8.5H8.5A4.5 4.5 0 0 1 4 12Z"/><path class="brand__cut" d="M8 8h4.5M8 11.2h3"/></svg>
          <span>Lumen</span><span class="brand__sub">Docs</span>
        </span>
        <span class="bar__search" aria-hidden="true">
          <svg viewBox="0 0 16 16"><circle cx="7" cy="7" r="4.6"/><path d="m10.4 10.4 3.2 3.2"/></svg>
          <span>Search</span><kbd>/</kbd>
        </span>
      </header>

      <nav class="trail" aria-label="Breadcrumb">
        <div class="trail__track" data-track>
          <span class="trail__pill" data-pill aria-hidden="true"></span>
          <ol class="trail__list" data-list></ol>
        </div>
        <div class="menu" data-menu role="menu" aria-label="Hidden levels" hidden></div>
      </nav>

      <div class="page" data-page>
        <div class="page__head">
          <h1 class="page__title"><span class="roll" data-title></span></h1>
          <p class="page__meta" data-meta></p>
        </div>
        <ul class="rows" data-rows></ul>
      </div>
      <p class="sr" aria-live="polite" data-live></p>
    </section>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

17 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Collapsing breadcrumbs” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

At the top of the Lumen page sits the path, Docs and Guides, with the guide’s folders below. Click Payments, then Webhooks, then Retries, and each level slides in from the right on a small spring while the page below changes: the title rolls, the rows leave to the left and come in from the right. At the fifth level Guides, Payments and Webhooks squeeze and fade towards a pill with three dots, leaving Docs and Retries. The pill opens a menu of the hidden levels, which drop in one after the other; pick one and the path shortens, the later levels leave and the crumbs all come back. The last one is bold with the icon of its kind of page, and a grey pill follows the pointer over the others.

How it works

Each crumb animates its width

Each level is an li with overflow hidden: GSAP takes its width from 0 to the size of its content (or back) with back.out, so the others slide along without computing positions. When it settles the width goes back to auto.

When to fold

The path folds when it has more levels than MAX_VISIBLE or when the real widths add up to more than the bar: the levels between the first and the last go to width 0, their text squeezes to scaleX 0.55 and fades, and the «…» pill comes in instead.

The menu of hidden levels

The pill opens a menu under it with the hidden levels, indented a little more at each level, dropping 7 pixels one after the other. A click outside or Esc closes it, and the arrow keys move through it.

The pill that follows the pointer

A single grey pill sits behind the row: on hover or focus it takes the crumb’s x and width on a spring, and it fades when the pointer leaves.

The page changes direction

Going in, the rows leave to the left and come in from the right; going back, the other way round. The title rolls the same way.

Values to change

NameFileDefaultWhat it changes
MAX_VISIBLEscript.js4How many levels the path shows before the middle ones fold into the «…» pill.
SPRINGscript.js1.6How far the crumbs overshoot when they open, fold and slide (0 = no bounce).
SHIFTscript.js14How many pixels a new level travels in from the right.
SPEEDscript.js1The speed of every movement (2 = twice as fast).
STEPscript.js1.5Seconds between one step and the next when the demo plays by itself.
--accentostyle.css#3651d4The one accent colour: the current level’s icon, the focus ring, the menu and the rows under the pointer.

Try them in the Playground

When to use it

At the top of the pages of a documentation site, a help centre, a drive or a dashboard with folders: wherever the path gets long and has to fit on a single line, phone included.

On phones

Everything is in em and the size follows the window’s width and height. On the phone the bar is narrow: the path folds as soon as it does not fit, leaving the first level, the dots and the last one. The search loses its label and the rows their second line. A tap does what a click does.

With reduced motion

No movement or springs: the crumbs fade in and out with their width already in place, the title and the rows crossfade, the menu appears without dropping.

Pitfalls

  • An li at width 0 with an inline-flex inside: the child only takes the content’s size if it has white-space nowrap, otherwise it wraps and the measured width is wrong.
  • With overflow hidden on the li the focus outline would be clipped: the focus is an inset box-shadow on the button.
  • The width has to go back to auto when the animation ends, or after the first resize the crumbs keep their old size.
  • The menu is rebuilt each time it opens, with the levels hidden at that moment: a fixed one would show levels that have already left.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 8.7 KB; the libraries: GSAP 28 KB.

Testing

Tested on 25 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All components