Skip to content
animorio
IT
All components

Newsletter nav

Navigation, HoverGSAP, CSS onlyMediumCompressed weight: Demo 10.0 KBGSAP 28 KBFreeDownload the zip

The navigation bar of Slow Margins, a made-up weekly newsletter: the mark with the latest issue and how many posts are still unread, the sections Essays, Notes, Reading and About, and Subscribe. Each section has its orange badge with the new posts. Choose one and the dark pill slides over on two springs, the front edge quicker than the back, takes the badge inside, counts the new posts down to a tick and closes the room they leave, while the sections after it draw closer and the line under the name counts down to All caught up.

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>
<!--
  "Newsletter 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 newsletter nav whose pill collects the new-post counts</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/opsz-italic.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- one gesture: the dark pill slides to a section on two springs, takes the section's new-post badge inside,
         counts it down to a tick and closes the gap it leaves; the unread line under the name counts down with it -->
    <nav class="nav" data-nav aria-label="Slow Margins">
      <span class="nav__grain" aria-hidden="true"></span>

      <a class="brand" href="#home" data-brand>
        <span class="brand__mark" aria-hidden="true">
          <svg viewBox="0 0 30 30">
            <rect class="m__tile" x="0.5" y="0.5" width="29" height="29" rx="8.5"></rect>
            <path class="m__page" d="M9.5 7.5h7.6l4.4 4.4v10.6H9.5Z"></path>
            <path class="m__fold" d="M17.1 7.5v4.4h4.4"></path>
            <path class="m__line" data-mline d="M12 15.4h6.9"></path>
            <path class="m__line" data-mline d="M12 18.6h4.6"></path>
          </svg>
        </span>
        <span class="brand__text">
          <span class="brand__name">Slow Margins</span>
          <span class="brand__meta">Issue&nbsp;<span class="roll" data-issue><span>48</span></span><span class="brand__sep">·</span><span class="roll roll--tail" data-tail><span><span class="roll" data-total><span>10</span></span>&nbsp;unread</span></span></span>
        </span>
      </a>

      <div class="links" data-links role="list">
        <span class="ghost" data-ghost aria-hidden="true"></span>
        <span class="pill" data-pill aria-hidden="true"><span class="pill__press" data-press><span class="pill__face" data-face></span><span class="pill__sheen" data-sheen></span></span></span>

        <a class="link" href="#essays" role="listitem" data-link data-new="3">
          <span class="link__word">Essays</span>
          <span class="slot" data-slot><span class="chip" data-chip><span class="roll" data-num><span>3</span></span><svg class="chip__tick" viewBox="0 0 12 12" aria-hidden="true"><path d="M2.8 6.3 5 8.4l4.2-4.6"></path></svg></span></span>
          <span class="sr" data-sr>, 3 new</span>
        </a>
        <a class="link" href="#notes" role="listitem" data-link data-new="5">
          <span class="link__word">Notes</span>
          <span class="slot" data-slot><span class="chip" data-chip><span class="roll" data-num><span>5</span></span><svg class="chip__tick" viewBox="0 0 12 12" aria-hidden="true"><path d="M2.8 6.3 5 8.4l4.2-4.6"></path></svg></span></span>
          <span class="sr" data-sr>, 5 new</span>
        </a>
        <a class="link" href="#reading" role="listitem" data-link data-new="2">
          <span class="link__word">Reading</span>
          <span class="slot" data-slot><span class="chip" data-chip><span class="roll" data-num><span>2</span></span><svg class="chip__tick" viewBox="0 0 12 12" aria-hidden="true"><path d="M2.8 6.3 5 8.4l4.2-4.6"></path></svg></span></span>
          <span class="sr" data-sr>, 2 new</span>
        </a>
        <a class="link is-on" href="#about" role="listitem" data-link data-new="0" aria-current="page">
          <span class="link__word">About</span>
        </a>
      </div>

      <button class="sub" type="button" data-sub aria-pressed="false">
        <span class="sub__light" data-sublight aria-hidden="true"></span>
        <span class="sub__icon" aria-hidden="true">
          <svg viewBox="0 0 16 16">
            <g data-env><rect x="2" y="3.6" width="12" height="8.8" rx="2"></rect><path d="m2.6 4.6 5.4 4 5.4-4"></path></g>
            <path class="sub__tick" data-subtick d="M3.6 8.4 6.6 11.2 12.4 5"></path>
          </svg>
        </span>
        <span class="roll sub__label" data-sublabel><span>Subscribe</span></span>
      </button>
    </nav>
  </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.

35 values to change

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 “Newsletter nav” 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

On a white ground, alone, the navigation bar of Slow Margins, a made-up weekly newsletter: a warm paper-coloured slab 60 pixels tall, with a 1px edge catching the light on top, a fine grain and a soft layered shadow. On the left the mark, a dark tile with a page with a folded corner and two orange lines, the name in italic and below it, small, Issue 48 · 10 unread; in the middle Essays, Notes, Reading and About; on the right the orange Subscribe button with a drawn envelope. Next to Essays, Notes and Reading an orange badge waits as a superscript with the new posts: 3, 5 and 2. The page you are on, About, sits on a dark pill. On arrival the bar rises into focus, the sections rise one after another and the badges pop in with a bounce. With the mouse on a section a light pill slides under it and its badge lifts by a pixel and a half; pressed, the word squashes slightly. Choose a section and the dark pill travels over on two springs, the front edge quicker than the back, so it stretches and flattens a little on the way, and on arrival it goes a pixel past and gathers itself. The badge drops from the superscript into the pill and the number rolls backwards, 3, 2, 1, with a small beat on every step, while the count under the name goes down with it; at the end the number leaves and a white tick draws itself, a light crosses the pill, the badge closes and the room it kept narrows: the sections after it draw closer and the pill follows on its spring. Once the last section is read the line under the name rolls to All caught up with a tick and the two lines of the mark turn grey. Subscribe takes a light that follows the pointer; pressed it squashes, the envelope flies off, a tick draws itself, the fill turns dark and the label rolls to Subscribed. Shortly after the new issue comes out: Issue 49, the lines of the mark redraw in orange, the gaps open again and the badges come back one after another. A demonstration round does it all by itself and stops as soon as the bar is touched.

How it works

Two springs for one pill

The dark pill has no tween: on every frame of the GSAP ticker its left and right edges chase the edges of the chosen section, each on its own damped spring. The leading edge is stiffer (STIFF), the trailing one gets a fraction of it (LAG): on the way the pill stretches, and its speed flattens it slightly.

The target is measured every time

The edges to reach are read from the section's getBoundingClientRect on every frame, not stored at the start. So when the room of a badge closes and the sections move, or the window is resized, the pill follows them on its spring with no extra work.

The badge that goes into the pill

Each badge sits in a 22-pixel slot after the word; at rest it is moved to a superscript with x, y and scale. When it is collected a timeline brings it onto the line with a back.out, calls the countdown steps, draws the tick with strokeDashoffset and closes the slot by taking its width to zero.

The rolling numbers

Each number is a small grid with hidden overflow: the new text enters the same cell from the side it counts towards, the old one leaves from the other with a touch of blur, and the cell's width goes from the old one to the new. The same piece counts the badge down, the unread line, the issue number and Subscribe.

Values to change

NameFileDefaultWhat it changes
ISSUEscript.js48The issue number written under the name.
STIFFscript.js420The stiffness of the spring on the pill's leading edge.
LAGscript.js0.55How much softer the trailing edge is: lower, and the pill stretches more on the way.
TICKscript.js0.15The seconds between one number and the next as the count goes down.
BOUNCEscript.js1.7How much the badges and the button bounce.
HOLDscript.js2.4The seconds the autopilot leaves Subscribed in view.
PAUSEscript.js0.9The seconds of rest between sections in the autopilot.
--inchiostrostyle.css#19171cThe colour of the pill, the mark and the name.
--accentostyle.css#f0582cThe orange of the badges and Subscribe.
--barrastyle.css#fcfbf9The paper colour of the bar.

Try them in the Playground

When to use it

At the top of a personal blog, a newsletter or an online magazine, when returning readers want to see at once what is new in each section: the badge says how many posts they have not seen yet and the pill clears them as soon as they go in.

On phones

Below 600 pixels the bar goes onto two rows: the mark and Subscribe on top, the four sections below, a little narrower on Mona Sans's width axis. The finger chooses like the mouse; without hover the light pill does not appear.

With reduced motion

No springs or rolling numbers: the dark pill fades out and back in on the chosen section, numbers and labels change with a fade, the badge fades away and its room closes at once.

Pitfalls

  • The pill is moved by the ticker with hand-written transform and width: a GSAP tween on its transform (the entrance scale) was wiped on the next frame. The scale goes on a child, pill__press, and the speed squash on another, pill__face.
  • The pill's target must be read on every frame: stored at the start, when a badge's room closed the pill stayed over the empty space.
  • The new width of a rolling number is measured on the new span with justify-self: start; otherwise the grid cell gave the width of the wider of old and new.
  • The new issue does not put the badge back on the section you are on: you are reading it, and a superscript badge inside the dark pill looked wrong.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, Newsreader (font variabile) 5.3.0.

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

Testing

Tested on 16 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