Skip to content
animorio
IT
All components

Compare tray

Tables, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.9 KBGSAP 28 KBFreeDownload the zip

The compare tray of Halden Audio, a made-up headphone shop, on white with a single cobalt blue. Three cards with drawn headphones: tick «Compare» and the box fills while the tick draws itself, the drawing flies on an arc into a dashed slot of the tray at the bottom and the «Compare (2)» counter rolls. With two or three products the black pill opens the tray into the comparison table: the tray rises on a spring, the rows for price, battery, weight, noise cancelling and fast charge arrive one after the other and the best value of each row lights up in blue. Back closes it, Clear empties everything.

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>
<!--
  "Compare tray" 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>Compare tray</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">
    <!-- three headphones in a made-up shop. Tick «Compare» on a card: its picture flies into the tray,
         the empty dashed slots fill and the counter rolls. Press Compare: the tray opens into the table,
         rows arrive one after the other and the best value of each row lights up. Clear puts everything back -->
    <section class="shop" data-shop aria-label="Halden Audio headphones">
      <header class="shop__head">
        <span class="brand">Halden Audio</span>
        <span class="crumb">Headphones <span class="sep">/</span> <strong>Wireless</strong></span>
      </header>

      <ul class="cards" data-cards>
        <li class="card" data-card="0">
          <div class="thumb" data-thumb>
            <svg viewBox="0 0 80 56" aria-hidden="true"><g class="ph">
              <path class="band" d="M20 34V27a20 20 0 0 1 40 0v7"/>
              <rect class="cup" x="13" y="29" width="12" height="18" rx="5"/>
              <rect class="cup" x="55" y="29" width="12" height="18" rx="5"/>
              <path class="pad" d="M25 32v12M55 32v12"/>
            </g></svg>
          </div>
          <p class="card__name">Arc 2</p>
          <p class="card__price">$249</p>
          <button class="check" type="button" role="checkbox" aria-checked="false" data-check>
            <span class="box"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="tick" pathLength="1" d="M4 8.4l2.6 2.5L12 5.4"/></svg></span>
            <span>Compare</span>
          </button>
        </li>
        <li class="card" data-card="1">
          <div class="thumb" data-thumb>
            <svg viewBox="0 0 80 56" aria-hidden="true"><g class="ph">
              <path class="band" d="M22 33v-5a18 18 0 0 1 36 0v5"/>
              <circle class="cup" cx="21" cy="38" r="8"/>
              <circle class="cup" cx="59" cy="38" r="8"/>
              <circle class="pad" cx="21" cy="38" r="3.4"/>
              <circle class="pad" cx="59" cy="38" r="3.4"/>
            </g></svg>
          </div>
          <p class="card__name">Arc Pro</p>
          <p class="card__price">$349</p>
          <button class="check" type="button" role="checkbox" aria-checked="false" data-check>
            <span class="box"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="tick" pathLength="1" d="M4 8.4l2.6 2.5L12 5.4"/></svg></span>
            <span>Compare</span>
          </button>
        </li>
        <li class="card" data-card="2">
          <div class="thumb" data-thumb>
            <svg viewBox="0 0 80 56" aria-hidden="true"><g class="ph">
              <rect class="cup" x="22" y="24" width="36" height="22" rx="11"/>
              <path class="pad" d="M22 34h36"/>
              <circle class="bud" cx="33" cy="17" r="4.6"/>
              <circle class="bud" cx="47" cy="17" r="4.6"/>
            </g></svg>
          </div>
          <p class="card__name">Drift Buds</p>
          <p class="card__price">$179</p>
          <button class="check" type="button" role="checkbox" aria-checked="false" data-check>
            <span class="box"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="tick" pathLength="1" d="M4 8.4l2.6 2.5L12 5.4"/></svg></span>
            <span>Compare</span>
          </button>
        </li>
      </ul>

      <!-- the tray: three slots, the counter and Compare. It opens into the table -->
      <div class="tray" data-tray>
        <div class="tray__bar" data-bar>
          <div class="slots" data-slots>
            <span class="slot" data-slot></span>
            <span class="slot" data-slot></span>
            <span class="slot" data-slot></span>
          </div>
          <button class="clear" type="button" data-clear>Clear</button>
          <button class="go" type="button" data-go>
            <span class="go__words" data-words>
              <span class="go__word" data-word="compare">Compare <span class="count">(<span class="num" data-num><b>0</b></span>)</span></span>
              <span class="go__word" data-word="back">Back</span>
            </span>
          </button>
        </div>

        <div class="table" data-table aria-hidden="true">
          <div class="row row--head" data-row>
            <span class="row__label">Model</span>
            <span class="cell" data-col="0"><b>Arc 2</b></span>
            <span class="cell" data-col="1"><b>Arc Pro</b></span>
            <span class="cell" data-col="2"><b>Drift Buds</b></span>
          </div>
          <div class="row" data-row data-best="2">
            <span class="row__label">Price</span>
            <span class="cell" data-col="0">$249</span><span class="cell" data-col="1">$349</span><span class="cell" data-col="2">$179</span>
          </div>
          <div class="row" data-row data-best="1">
            <span class="row__label">Battery</span>
            <span class="cell" data-col="0">40 h</span><span class="cell" data-col="1">60 h</span><span class="cell" data-col="2">8 h</span>
          </div>
          <div class="row" data-row data-best="2">
            <span class="row__label">Weight</span>
            <span class="cell" data-col="0">254 g</span><span class="cell" data-col="1">288 g</span><span class="cell" data-col="2">52 g</span>
          </div>
          <div class="row" data-row data-best="1">
            <span class="row__label">Noise cancelling</span>
            <span class="cell" data-col="0">Standard</span><span class="cell" data-col="1">Adaptive</span><span class="cell" data-col="2">Standard</span>
          </div>
          <div class="row" data-row data-best="0">
            <span class="row__label">Fast charge</span>
            <span class="cell" data-col="0">10 min = 6 h</span><span class="cell" data-col="1">10 min = 4 h</span><span class="cell" data-col="2">10 min = 1 h</span>
          </div>
        </div>
      </div>
      <p class="sr" aria-live="polite" data-live></p>
    </section>
  </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.

60 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Compare tray” 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

The Halden Audio shop shows three headphones, Arc 2, Arc Pro and Drift Buds, each with its line drawing, its price and the «Compare» box; at the bottom sits the compare tray with three dashed slots, Clear and the «Compare (0)» pill, switched off. Tick a headphone and the box fills with blue from the centre with a small bounce while the tick draws itself; the drawing leaves the card, flies on an arc into the free slot of the tray and lands with a bounce, while the number rolls and the tray shadow grows. With two products the pill switches on: on click the tray rises on a spring until it covers the cards, the table opens with its rows arriving one after the other, and in every row the best value turns blue with a pale band widening behind it. The pill becomes «Back» and closes the table; Clear removes the ticks one by one and empties the slots.

How it works

The order of the picks

A list keeps the cards in the order they were ticked: the slot in the tray is the position in the list, and when a card is removed the others slide to the left.

The flight

The card drawing is copied into a fixed element; a number from 0 to 1 moves it along a quadratic curve with a lifted middle point, while the scale goes from the card to the size of the slot. On arrival the copy disappears and the slot gets the drawing with a back.out.

The tray opening

The tray is as tall as its row; to open it GSAP takes its height to the size of the shop, measured in pixels and remeasured on resize, with a light back.out. The table rows come in staggered and only at the end do the best values light up.

The best value

Each row says in data-best which column wins; if that product was picked, the cell turns blue and a pale band widens behind it with an elastic. The columns that were not picked stay faded.

The pill label

Compare and Back sit on top of each other out of the flow, in a box as wide as the visible one: when the word changes the box springs to the new width, and the pill follows it.

Values to change

NameFileDefaultWhat it changes
FLIGHTscript.js0.62Seconds of the drawing’s flight from the card to the tray.
ARCscript.js46How high the drawing lifts during the flight, in pixels.
OPENscript.js0.75Seconds the tray takes to open into the table.
ROW_STAGGERscript.js0.06Seconds between one table row and the next.
PRESSscript.js0.95Scale of the pill while pressed.
AUTO_PAUSEscript.js6Seconds of quiet before the demo plays by itself again.

Try them in the Playground

When to use it

In shops with similar products to choose between (headphones, phones, bikes, mattresses, service plans): wherever buyers want to put two or three things side by side without leaving the page.

On phones

Everything is in em and the size follows both the width and the height of the window, so shop, tray and table fit the phone box. A tap works like a click; the height of the open tray is measured again when the window changes.

With reduced motion

No flights or springs: the tick appears already drawn, the drawing appears straight in the slot, the number changes without rolling and the table fades in with the best values already lit.

Pitfalls

  • The two labels of the pill sit out of the flow in a box with a measured width: a hidden nowrap label in the flow would widen the pill and push Compare off centre.
  • The height of the open tray is in pixels, so it is redone on resize: the demo window changes height even while the table is open.
  • The flying drawing lives in a fixed element outside the card, or the card’s overflow would clip it.
  • The tick uses stroke-dashoffset with pathLength 1: autoRound has to be off, or it pops in at once.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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