Skip to content
animorio
IT
All components

Menu course picker

Tabs, Transitions, ImagesGSAP, CSS onlyMediumCompressed weight: Demo 9.6 KBGSAP 28 KBFreeDownload the zip

The dinner card of Trattoria Lume, a made up restaurant, dark and warm on black: a segmented control with four courses, Starters, Pasta, Mains and Desserts, and a pill that slides on a spring, stretching towards the course and catching up with its back edge. Below, the real photo of the dish comes in from the same side, with a slight zoom and film grain, while the previous photo darkens and steps back; the dish name and the ingredients slide the same way and the price rolls on its digits. On the pasta a saffron ‘Chef's pick’ badge pops 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>
<!--
  "Menu course picker" 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 menu course picker with the sliding dish photo</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/fraunces@5.3.0/opsz.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the dinner card of Trattoria Lume: a segmented control with four courses and a pill that slides on a spring
         (its two edges have their own springs, so it stretches towards the course and catches up); under it the real
         photo of the course's dish slides in from the same side, with a slight zoom and film grain, then the dish name,
         its ingredients and the price rolling on its digits -->
    <article class="menu" data-menu>
      <span class="menu__sheen" aria-hidden="true"></span>

      <header class="menu__head">
        <span class="menu__brand">
          <svg class="menu__mark" viewBox="0 0 20 20" aria-hidden="true">
            <path d="M10 2.6c2.2 2.6 3.4 4.6 3.4 6.6a3.4 3.4 0 0 1-6.8 0c0-2 1.2-4 3.4-6.6z"/>
            <path d="M5.2 15.6h9.6M7 17.6h6"/>
          </svg>
          <span class="menu__name">Trattoria Lume</span>
        </span>
        <span class="menu__when">Dinner <span class="menu__dot">·</span> 7 to 11 pm</span>
      </header>

      <div class="seg" role="tablist" aria-label="Courses" data-seg>
        <span class="seg__hover" data-hover aria-hidden="true"></span>
        <span class="seg__pill" data-pill aria-hidden="true"><span class="seg__pill-face"></span></span>
        <button class="seg__tab" type="button" role="tab" id="tab-starters" aria-controls="dish" aria-selected="true" tabindex="0" data-tab><span>Starters</span></button>
        <button class="seg__tab" type="button" role="tab" id="tab-pasta" aria-controls="dish" aria-selected="false" tabindex="-1" data-tab><span>Pasta</span></button>
        <button class="seg__tab" type="button" role="tab" id="tab-mains" aria-controls="dish" aria-selected="false" tabindex="-1" data-tab><span>Mains</span></button>
        <button class="seg__tab" type="button" role="tab" id="tab-desserts" aria-controls="dish" aria-selected="false" tabindex="-1" data-tab><span>Desserts</span></button>
      </div>

      <section class="dish" id="dish" role="tabpanel" aria-labelledby="tab-starters" data-panel>
        <div class="photo" data-photo>
          <figure class="photo__layer" data-layer><img class="photo__img" src="starters.webp" width="1024" height="769" alt="Bruschetta with chopped tomatoes on grilled bread"></figure>
          <figure class="photo__layer" data-layer><img class="photo__img" src="pasta.webp" width="1024" height="683" alt="Tagliatelle with slow ragù and shaved pecorino"></figure>
          <figure class="photo__layer" data-layer><img class="photo__img" src="mains.webp" width="960" height="640" alt="Grilled salmon with charred peppers and herb yogurt"></figure>
          <figure class="photo__layer" data-layer><img class="photo__img" src="desserts.webp" width="1024" height="683" alt="Tiramisu with cocoa and dark chocolate shavings"></figure>
          <span class="photo__shade" aria-hidden="true"></span>
          <span class="photo__grain" aria-hidden="true"></span>
          <span class="photo__edge" aria-hidden="true"></span>
          <span class="pick" data-pick>
            <svg class="pick__icon" viewBox="0 0 16 16" aria-hidden="true">
              <path d="M4.4 9.6c-1.6-.3-2.5-1.5-2.3-2.9.2-1.3 1.5-2.2 2.9-2 .5-1.3 1.7-2.1 3-2.1s2.5.8 3 2.1c1.4-.2 2.7.7 2.9 2 .2 1.4-.7 2.6-2.3 2.9V13H4.4z"/>
              <path d="M4.4 11h7.2"/>
            </svg>
            <span>Chef's pick</span>
          </span>
          <span class="count" aria-hidden="true"><span data-count>4 pieces</span></span>
        </div>

        <div class="info">
          <div class="info__text">
            <h2 class="info__name"><span class="info__mask"><span data-name>Bruschetta al pomodoro</span></span></h2>
            <p class="info__line"><span class="info__mask"><span data-line>Datterini, garlic, basil, grilled sourdough</span></span></p>
          </div>
          <p class="price" aria-label="11 euros" data-price>
            <span class="price__cur">€</span>
            <span class="price__col" data-col></span>
            <span class="price__col" data-col></span>
          </p>
        </div>
      </section>

      <footer class="menu__foot">
        <span class="menu__note" data-note>Vegetarian</span>
        <button class="menu__add" type="button" data-add>
          <span class="menu__add-face">
            <svg viewBox="0 0 16 16" aria-hidden="true"><path class="menu__plus" data-plus d="M8 3.5v9M3.5 8h9"/><path class="menu__tick" data-tick pathLength="1" d="M3.6 8.4l2.9 2.9 5.9-6.4"/></svg>
            <span data-add-words>Add to order</span>
          </span>
        </button>
      </footer>
    </article>
    <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.

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 “Menu course picker” 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 black a dark walnut card with round corners rises, with a warm light on its top edge, as from a lamp over the table. At the top the name Trattoria Lume with a small drawn flame and the dinner hours; below, in a sunken track, the four courses: Starters, Pasta, Mains, Desserts. The raised pill sits on the chosen course. When another one is chosen, the leading edge leaves first and the back edge follows more softly: the pill stretches towards the course, reaches it, passes the mark by a pixel and settles; the chosen label widens a little. Below, the photo of the dish slides in from the same side, zoomed in and a little brighter, and settles; the previous one darkens and steps back by a quarter. On the photo there is a flickering film grain, a shadow at the bottom and, in the corner, a small label that rolls (4 pieces, Rolled by hand, Line caught, Serves one). The dish name, in a serif face, and the ingredients leave and come back in the pill's direction; the price in euros rolls on its two digits. On the pasta the saffron ‘Chef's pick’ badge with the chef's hat pops up with a bounce, and the pilot presses ‘Add to order’: the button gives, comes back on an elastic, the plus turns and makes way for a checkmark that draws itself and the word ‘Added’. Hovering the courses a faint ghost pill follows the pointer; on a press the label and the pill give under the finger. From the keyboard the arrows, Home and End change course.

How it works

A pill with two edges

The pill is not driven by a tween: its left and right edges are two separate springs, integrated every frame in four steps (largest step 1/30 of a second). The leading edge has the full stiffness, the back edge LAG times less, with the damping scaled to keep the same bounce: so it stretches towards the course and shortens as it arrives. A click mid-flight only changes the targets.

The photo comes in from the right side

The four photos are stacked, each in its own frame with hidden overflow. The new frame goes on top and arrives from xPercent ±100 with expo.out; the photo inside starts at a 1.14 zoom with its origin towards the side it comes from and brightness at 112%. The old frame steps back a quarter and its photo drops to 42% light: it looks pushed under.

Grain and shadows over the photo

Over the photos sit three still layers: a gradient shade with the vignette, the grain of an feTurbulence in an SVG background, in overlay, jumping in six steps every 0.9 s, and a 1 px edge catching the light at the top. After it lands the photo keeps easing from 1.02 to 1 over six seconds, like a camera that has not quite stopped.

Words and digits the same way

Name and ingredients leave by 14 px towards the opposite side and come back 22 px from the pill's side with back.out, 0.06 s apart. The price has two columns with the digits 0 to 9 stacked: each goes to yPercent −digit×10 with back.out(1.25), and the digit on the side of the movement starts first.

The pilot and the hand

A GSAP delayedCall moves to the next course after DWELL seconds and, on the chef's course, presses Add to order halfway through. A pointerdown or a key inside the card stops the pilot and restarts it after eight quiet seconds.

Values to change

NameFileDefaultWhat it changes
STIFFNESSscript.js260The spring of the pill's leading edge: higher is quicker.
DAMPINGscript.js21Lower lets the pill pass the mark and come back.
LAGscript.js0.5How much softer the back edge is: lower stretches the pill more.
SLIDE_TIMEscript.js0.95The seconds of the photo sliding in.
ZOOMscript.js1.14How much the photo is zoomed in when it arrives.
GRAINscript.js0.2How visible the grain on the photo is.
CHEF_PICKscript.js1The course with the Chef's pick badge: 0 starters, 1 pasta, 2 mains, 3 desserts.
DWELLscript.js2.8The seconds the pilot stays on each course.
LOOPscript.jstrueThe pilot goes through the courses again and again.

Try them in the Playground

When to use it

For the menu of a restaurant, a trattoria, a bistro or a bar on its site or in a booking and ordering app: the courses as tabs, with the dish photo and the price, and the chef's suggestion standing out.

On phones

The same animation with adapted sizes: the card is 92% of the screen wide, the photo and the margins are measured on the height too, the course labels tighten and the pill is measured again at every width change, even mid-flight. A finger taps the course and presses the button.

With reduced motion

Nothing moves: the pill fades out and back in on the new course, the new photo fades in over the old one, words, price and badge change with a fade, the grain stays still.

Pitfalls

  • With a single tween the pill slid stiffly; with two equal springs on the edges it did not stretch. The back edge needs the lower stiffness but also the damping scaled by the square root of the ratio, or it arrives slowly and without the one pixel bounce.
  • Moving the photo inside its frame for a parallax left a strip of the frame bare while it came in: the photo moves only a little (6%) and starts already zoomed, so it always covers everything.
  • The pill's sizes are in pixels and the font arrives after load: it is measured again when document.fonts is ready and at every width change with a ResizeObserver, changing only the springs' target if the pill is travelling.

Libraries

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

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

Testing

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