
Hide-on-scroll top bar
Navigation, Scroll, Hover
New
Scroll inside the preview
The navigation bar of a SaaS site, as wide as the page at the top: scrolling down it lifts off the edge and gathers on a short spring into a frosted glass pill in the middle, with the same links. The wordmark folds away behind the symbol, Get started shortens to Start, a hairline border and a shadow that grows as you read appear; back at the top it opens out wide. A soft pill slides under the link you point at. Morphin style, clean, on the palest grey.
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>
<!--
"Scroll pill nav" 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>The nav that shrinks into a pill on scroll</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>
<!-- the header of a docs tool: wide across the page at the top; scrolling down it lifts off the edge and gathers on a
spring into a centred frosted pill, the wordmark folds away behind the symbol and the button shortens to Start.
A soft pill slides under the link you point at. Scrolling back to the top it opens out again. -->
<header class="nav" data-nav>
<div class="nav__shape" data-shape>
<div class="nav__inner">
<a class="brand" href="#" aria-label="Docwell, home">
<svg class="brand__mark" data-mark viewBox="0 0 24 24" aria-hidden="true">
<rect x="3.5" y="3.5" width="17" height="17" rx="5.5"></rect>
<path d="M8.5 9h7M8.5 12h7M8.5 15h4"></path>
</svg>
<span class="brand__word" data-word><span class="brand__text" data-word-text>Docwell</span></span>
</a>
<nav class="links" data-links aria-label="Main">
<span class="links__hl" data-hl aria-hidden="true"></span>
<a class="link is-active" href="#" data-link aria-current="page">Product</a>
<a class="link" href="#" data-link>Pricing</a>
<a class="link link--wide" href="#" data-link>Customers</a>
<a class="link link--wide" href="#" data-link>Docs</a>
</nav>
<a class="cta" href="#" data-cta>
<span class="cta__labels" data-labels>
<span class="cta__label cta__label--long" data-long>Get started</span>
<span class="cta__label cta__label--short" data-short aria-hidden="true">Start</span>
</span>
<svg class="cta__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8h8.5M8.8 4.6 12.2 8l-3.4 3.4"></path></svg>
</a>
</div>
</div>
</header>
<main class="page">
<section class="hero">
<p class="hero__tag">Docwell for teams</p>
<h1 class="hero__title">Docs your team actually reads.</h1>
<p class="hero__sub">Write once, link everywhere. Docwell keeps specs, guides and decisions in one calm place.</p>
<div class="hero__ctas"><span class="ghost ghost--dark"></span><span class="ghost"></span></div>
<p class="hero__hint" data-hint>Scroll down</p>
</section>
<section class="block">
<div class="lines"><span style="--w: 42%"></span><span style="--w: 76%"></span><span style="--w: 64%"></span></div>
<div class="cards">
<div class="card"><span class="card__icon"></span><span class="card__line" style="--w: 70%"></span><span class="card__line" style="--w: 90%"></span><span class="card__line" style="--w: 55%"></span></div>
<div class="card"><span class="card__icon"></span><span class="card__line" style="--w: 60%"></span><span class="card__line" style="--w: 85%"></span><span class="card__line" style="--w: 70%"></span></div>
<div class="card"><span class="card__icon"></span><span class="card__line" style="--w: 75%"></span><span class="card__line" style="--w: 50%"></span><span class="card__line" style="--w: 80%"></span></div>
</div>
</section>
<section class="block">
<div class="lines"><span style="--w: 36%"></span><span style="--w: 70%"></span></div>
<div class="panel"><span class="panel__bar"></span><span class="panel__row" style="--w: 82%"></span><span class="panel__row" style="--w: 64%"></span><span class="panel__row" style="--w: 74%"></span><span class="panel__row" style="--w: 48%"></span></div>
</section>
<section class="block block--end">
<p class="end__title">Start writing in two minutes.</p>
<div class="lines lines--centre"><span style="--w: 58%"></span></div>
</section>
</main>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lenis@1.3.26/dist/lenis.min.js"></script>
<script src="script.js"></script>
</body>
</html>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.
28 values to change
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 “Scroll pill nav” from Animorio and fit it into my siteThe header is a single element, and everything that changes (width, height, place, corners, padding) is a mix between the wide size and the pill size, driven by a number p from 0 to 1. So the spring’s bounce is the bounce of the whole bar, and no piece arrives before the others.
Scrolling only decides where p should go (0 above SHRINK_AT pixels, 1 below); every frame a spring with stiffness and damping takes it there, in two half steps to stay stable. The spring’s speed also tilts the symbol.
The width of the pill is the sum of what it holds: the symbol, the visible links, the short button and the padding. It is measured again on every resize, and on a phone only two links stay.
Background, blur, border and shadow read the --p and --s variables in CSS with calc(): the script writes just two numbers, and the glass, the hairline and the shadow growing with the scroll work themselves out.
| Name | File | Default | What it changes |
|---|---|---|---|
SHRINK_AT | script.js | 80 | How many pixels down the page the bar becomes a pill. |
STIFFNESS | script.js | 320 | How stiff the bar’s spring is. |
DAMPING | script.js | 0.72 | How much the spring is held back (1 = no bounce). |
PILL_HEIGHT | script.js | 52 | The height of the pill, in pixels. |
PILL_TOP | script.js | 12 | The gap between the pill and the top edge, in pixels. |
HIGHLIGHT | script.js | 0.38 | How many seconds the grey pill takes to slide under a link. |
TOUR | script.js | 2.1 | When nobody points, every how many seconds the grey pill moves to the next link (0 = never). |
For the header of a product site, a SaaS tool or a landing page: wide and calm at the top, where there is room, and gathered into a pill while you read, so it takes little space and stays within reach.
The same spring and the same pill: two links stay, Product and Pricing, the wordmark folds away the same way and the pill sits 8 pixels from the edge, at most the screen width minus 16 pixels. The grey pill moves on tap.
No spring and no smooth scrolling: the bar switches from wide to pill and back at once, the symbol does not lean and the grey pill jumps under the link without sliding.
GSAP 3.15.0, Lenis 1.3.26, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 6.6 KB; the libraries: GSAP 28 KB, Lenis 5.3 KB.
Tested on 26 October 2026
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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.