Skip to content
animorio
IT
Back to the library

Menu item swell transition

Transitions, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.8 KBGSAP 28 KBFreeDownload the zip

The four pages of a made-up clay studio, Halvard, each in its own full colour: oat, terracotta, moss and cobalt. Click an item on the menu bar at the bottom and it lifts off as a pill in the colour of the next page, opens into a card in the middle with a highlight crossing it, then swells to cover the screen and becomes the new page's background; meanwhile its word flies up and becomes the huge title. Leaving and arriving get the same care: the old page steps back, the new one arrives one part after the other.

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>
<!--
  "Menu item swell transition" 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 page transition where the menu item swells into the page</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/full.css">
  <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" data-stage data-page-now="studio">
    <!-- the four pages of a made-up clay studio by the harbour, Halvard. Every page has its own full colour. A click on
         the menu at the bottom lifts the item off the bar as a pill in the colour of the page that is coming, the pill
         opens into a card, the card swells until it covers the screen, and the word of the item flies up to become the
         huge title of the new page -->

    <header class="top">
      <a href="#" class="brand" data-go="studio" aria-label="Halvard clay studio, home">
        <svg class="brand__mark" viewBox="0 0 24 24" aria-hidden="true">
          <circle cx="12" cy="12" r="8.6"></circle>
          <path d="M7.4 14.6c2.8 1.6 6.4 1.6 9.2 0"></path>
        </svg>
        <span class="brand__name">Halvard</span>
      </a>
      <a href="#" class="shop" data-go="visit"><span>Book a class</span>
        <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8h8.5M8.6 4.4 12.2 8l-3.6 3.6"></path></svg>
      </a>
    </header>

    <div class="pages">
      <section class="page is-on" data-page="studio" aria-label="Studio">
        <p class="eyebrow" data-in>A small clay studio by the harbour</p>
        <h1 class="title" data-title>Studio</h1>
        <div class="foot">
          <p class="text" data-in>Hand-thrown tableware for restaurants and homes, fired twice in a wood kiln.</p>
          <div class="card" data-in>
            <span class="card__small">Next kiln opening</span>
            <span class="card__mid">Sat 22 Nov</span>
          </div>
        </div>
      </section>

      <section class="page" data-page="work" aria-label="Work" hidden>
        <p class="eyebrow" data-in>Selected pieces</p>
        <h1 class="title" data-title>Work</h1>
        <div class="foot">
          <p class="text" data-in>Plates, bowls and tall jugs, made in small runs of forty and never twice the same.</p>
          <div class="card" data-in>
            <span class="card__small">This season</span>
            <span class="card__mid">128 pieces</span>
          </div>
        </div>
      </section>

      <section class="page" data-page="journal" aria-label="Journal" hidden>
        <p class="eyebrow" data-in>Notes from the wheel</p>
        <h1 class="title" data-title>Journal</h1>
        <div class="foot">
          <p class="text" data-in>On ash glazes, slow mornings and the kiln that never quite behaves.</p>
          <div class="card" data-in>
            <span class="card__small">New entry</span>
            <span class="card__mid">The blue that took a year</span>
          </div>
        </div>
      </section>

      <section class="page" data-page="visit" aria-label="Visit" hidden>
        <p class="eyebrow" data-in>Open Thursday to Sunday</p>
        <h1 class="title" data-title>Visit</h1>
        <div class="foot">
          <p class="text" data-in>Come to the studio, sit at the wheel for two hours and take a bowl home.</p>
          <div class="card" data-in>
            <span class="card__small">Two-hour class</span>
            <span class="card__mid">&euro;65 per person</span>
          </div>
        </div>
      </section>
    </div>

    <!-- the swelling pill and the flying word live above the pages and below the menu -->
    <div class="blob" data-blob aria-hidden="true"><span class="blob__shine" data-shine></span></div>
    <span class="word" data-word aria-hidden="true"></span>

    <nav class="nav" data-nav aria-label="Main">
      <span class="nav__hover" data-hover aria-hidden="true"></span>
      <span class="nav__pill" data-pill aria-hidden="true"><span class="nav__gloss"></span></span>
      <a href="#" class="nav__item is-here" data-go="studio" aria-current="page"><span>Studio</span></a>
      <a href="#" class="nav__item" data-go="work"><span>Work</span></a>
      <a href="#" class="nav__item" data-go="journal"><span>Journal</span></a>
      <a href="#" class="nav__item" data-go="visit"><span>Visit</span></a>
    </nav>

    <div class="grain" aria-hidden="true"></div>
    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.5l13 7.2-5.6 1.4-2.8 5.4z"></path></svg>
    <p class="sr" aria-live="polite" data-live></p>
  </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.

46 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 “Menu item swell transition” 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 an oat background with fine grain sits the Studio page of Halvard, a clay studio by the harbour: at the top the mark and the «Book a class» button, in the middle the huge title in a soft serif, below a line and a small card. At the bottom a dark glass bar with the four items, Studio, Work, Journal and Visit, and a cream pill under the current one. Click an item and it squashes slightly, then a pill in the colour of the next page lifts off the bar with the word inside; the pill opens into a card in the middle of the screen while the old page steps back and disappears, a highlight crosses it, and the card swells to the edges. When it covers everything it is already the new page's background: the word, which has meanwhile flown up and grown, has become the title, which settles by a hair; the line and the card arrive one after the other. The cream pill slides onto the new item, stretching. Left alone, a drawn pointer tours the pages by itself.

How it works

The new page is measured first, invisible

On click the next page is shown with visibility: hidden, so the position and font size of its title can be read: that is where the word will land.

The word is born big and shrinks onto the item

The flying word already has the title's size; it is scaled down (transform-origin top left) until it is as wide as the menu item and moved over it. The trip then brings the scale back to 1: no font-size change, so no jumps.

Pill, card, screen

One div does it all: it starts as the item's rectangle with a radius of half its height, lifts by 10 px, opens into a card in the middle in 0.55 s on power3.inOut, then swells to the edges and a radius of 0 in 0.75 s on expo.inOut. Width, height and radius are written in pixels, so the shadow and the edge of light don't stretch.

The swap

When the card covers the screen the colour moves to the page background, the old page hides, the real title takes the word's place and the card disappears: nobody sees the change. Then the title settles from 1.012 on a spring and the rest comes in from 18 px below, 0.08 s apart.

Values to change

NameFileDefaultWhat it changes
PRESSscript.js0.16The seconds of the press on the menu item, before it lifts off the bar.
LIFTscript.js10How many pixels the pill rises as it lifts off the bar.
CARDscript.js0.55The seconds in which the pill opens into a card in the middle of the screen.
FILLscript.js0.75The seconds in which the card swells to cover the screen while the word flies to the title.
CARD_WIDTHscript.js0.62How wide the halfway card is, as a share of the width (at most 600 px).
CARD_RADIUSscript.js28The corner radius of the halfway card.
STAGGERscript.js0.08The seconds between one part of the new page and the next as it comes in.
SHINEscript.js1The highlight crossing the card as it opens (1 on, 0 off).
HOVER_PULLscript.js3How many pixels the menu items lean towards the pointer.
AUTO_EVERYscript.js1.6Left alone, the seconds of rest on each page before the next lap.

Try them in the Playground

When to use it

For the site of a studio, a workshop, a small brand or a portfolio with few pages, each in its own colour: when the menu should feel like an object and the page change should start from the click and say at once where you are going.

On phones

The same transition with adapted sizes: the bar stays at the bottom centre with narrower items, the title is sized on width and height, the line and the card stack, and in the short box only the card stays. The pill starts from the tapped item; no items leaning towards the pointer.

With reduced motion

No swelling pill and no flying word: the new page's colour fades in over 0.35 s and the page fades in; the cream pill jumps to its place.

Pitfalls

  • The word must not be animated with font-size: lines and kerning would change on every frame. It is born at the title's size and travels with scale only.
  • The next page must be measured with visibility: hidden, not display: none, otherwise the title has no size.
  • The menu bar is centred with margin auto, not translateX(-50%): GSAP animates it with yPercent and would wipe the class transform.
  • A resize halfway through jumps the timeline to its end and measures everything again: the card's sizes are in pixels.

Libraries

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

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

Testing

Tested on 8 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 animations