Skip to content
animorio
IT
Back to the library

Allergen filter menu

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

A restaurant’s online menu with four chips to say what you cannot eat: gluten, dairy, nuts, shellfish. Switching one on, the dishes that contain it lose colour, their tag lights up red and they slide to the bottom of the list on a spring, while the suitable ones move up; at the top the number of dishes left rolls.

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>
<!--
  "Allergen filter menu" 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>Restaurant menu with allergen filters and dishes that reorder</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">
    <!-- a restaurant's online menu: four chips say what you cannot eat; switching one on, the dishes that contain it
         lose colour, their allergen tag lights up and they slide to the bottom of the list on a spring while the safe
         ones move up; the line at the top counts how many dishes are left for you -->
    <section class="menu" data-menu aria-label="Dinner menu">
      <header class="head">
        <div>
          <p class="head__brand">Fig &amp; Fennel</p>
          <h1 class="head__title">Dinner menu</h1>
        </div>
        <p class="head__fit"><span class="head__n"><span data-fit>6</span></span><span class="head__l" data-fit-label>dishes for you</span></p>
      </header>

      <div class="chips" role="group" aria-label="Leave out">
        <button class="chip" type="button" data-chip="gluten" aria-pressed="false"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8"></path></svg><span>Gluten</span></button>
        <button class="chip" type="button" data-chip="dairy" aria-pressed="false"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8"></path></svg><span>Dairy</span></button>
        <button class="chip" type="button" data-chip="nuts" aria-pressed="false"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8"></path></svg><span>Nuts</span></button>
        <button class="chip" type="button" data-chip="shellfish" aria-pressed="false"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8"></path></svg><span>Shellfish</span></button>
      </div>

      <ul class="dishes" data-dishes>
        <li class="dish" data-has="dairy"><div class="dish__in"><p class="dish__name">Burrata, tomato, basil oil</p><p class="dish__tags"><span data-tag="dairy">dairy</span></p><p class="dish__price">14</p></div></li>
        <li class="dish" data-has="nuts"><div class="dish__in"><p class="dish__name">Charred leeks, hazelnut</p><p class="dish__tags"><span data-tag="nuts">nuts</span></p><p class="dish__price">12</p></div></li>
        <li class="dish" data-has="gluten"><div class="dish__in"><p class="dish__name">Tagliatelle, slow beef ragù</p><p class="dish__tags"><span data-tag="gluten">gluten</span></p><p class="dish__price">18</p></div></li>
        <li class="dish" data-has="shellfish dairy"><div class="dish__in"><p class="dish__name">Prawn risotto, lemon</p><p class="dish__tags"><span data-tag="shellfish">shellfish</span><span data-tag="dairy">dairy</span></p><p class="dish__price">22</p></div></li>
        <li class="dish" data-has=""><div class="dish__in"><p class="dish__name">Grilled sea bass, fennel</p><p class="dish__tags"><span class="dish__free">free of all four</span></p><p class="dish__price">26</p></div></li>
        <li class="dish" data-has="nuts gluten dairy"><div class="dish__in"><p class="dish__name">Pistachio cake, cream</p><p class="dish__tags"><span data-tag="nuts">nuts</span><span data-tag="gluten">gluten</span><span data-tag="dairy">dairy</span></p><p class="dish__price">9</p></div></li>
      </ul>
    </section>
    <p class="sr" data-live aria-live="polite"></p>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></svg>
  </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.

40 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 “Allergen filter menu” 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

In the middle, on a cream background, a white card: at the head the place’s name, ‘Dinner menu’ and, on the right, how many dishes suit you. Below, four chips: Gluten, Dairy, Nuts, Shellfish. Then six dishes, each with its name, its price and in small type the allergens it contains; on opening they come up one after the other. Tapping Gluten the chip turns black and a small cross appears in it; the tagliatelle and the pistachio cake lose colour, the word ‘gluten’ under their name turns red and heavier, and the two dishes slide to the bottom of the list moving slightly sideways to pass in front of the others, while the suitable dishes move up to take their place with a small settle; the number at the top rolls from 6 to 4. With Dairy two more go down, with Nuts only the sea bass is left. Switching a chip off the dishes come back up, always in the menu’s order. Left alone, a pointer switches three filters on and off.

How it works

What each dish contains

Each row has data-has with its allergens; the chips that are on live in a Set. A dish is ‘out’ if one of its allergens is in the Set: it takes the is-out class and the tags hit take is-hit.

First, last, invert, play

Before reordering, the position of each row is measured; then the rows are put back in the DOM (suitable ones first, then the others, each in the menu’s order), measured again, and each row starts from the difference and returns to zero with a heavily damped elastic.out.

Whoever overtakes steps aside

A row that moves by more than 4 pixels goes above the others with z-index, and its content shifts LIFT pixels sideways and back: it looks like it is making its way.

The number at the top

It rolls up when the dishes go down in number and down when they come back; next to it the word goes from ‘dishes’ to ‘dish’ when one is left.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#d6482aThe colour of the allergen found in a dish.
SPRINGscript.js0.75How long the spring of the dishes changing place lasts, in seconds.
STAGGERscript.js0.035The delay between one dish and the next, in seconds.
LIFTscript.js6By how many pixels a dish shifts while it overtakes the others.
PACEscript.js1.4By itself: the pause after each filter, in seconds.
LOOPscript.jstrueLeft alone, a pointer switches the filters on and off.

Try them in the Playground

When to use it

For the online menu of a restaurant, a bar, a pastry shop or a delivery service: someone with an allergy sees at once what they can order, without the dishes disappearing. The same reordering suits any list to filter while keeping visible what is left out.

On phones

The same card, as wide as the screen: the four chips share the row, long names are cut with an ellipsis and, on narrow screens, the words next to the number disappear. On a short screen the rows tighten by a few pixels.

With reduced motion

No sliding: the dishes change place at once and change colour with a fade; the number changes with a fade.

Pitfalls

  • If a filter arrives while the rows are still moving, the starting position must be read from the screen (getBoundingClientRect), not from the layout: otherwise the rows jump.
  • The sideways move sits on the row’s content and the slide on the row: two elements, because two tweens on the same transform cancel each other.
  • This filter is a help, not a guarantee: a real site must say that for serious allergies you need to ask the staff.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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