Skip to content
animorio
IT
All components

Cookie preferences

Consent, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 10 KBGSAP 28 KBFreeDownload the zip

The cookie consent of an invented site, dark on black with a single amber colour: the bar at the bottom, on Customize, grows on a spring into the preferences card, with a light running along its edge. The category switches turn on one after another with a stretching knob and a rolling count, Analytics opens to say what it does and the card rises with it, and Save folds everything into a small confirmation pill with a check drawing itself.

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>
<!--
  "Cookie preferences" 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 cookie preferences growing out of the bar</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" data-stage>
    <!-- one shell that changes shape: the cookie bar at the bottom grows into the preferences card,
         and saving folds it into a small confirmation pill -->
    <div class="glow" data-glow aria-hidden="true"></div>
    <div class="frame" data-frame aria-hidden="true"></div>
    <section class="shell" data-shell aria-label="Selvane cookie preferences">
      <span class="shell__sheen" data-sheen aria-hidden="true"></span>

      <!-- the bar -->
      <div class="layer bar" data-bar>
        <span class="tile" aria-hidden="true">
          <svg viewBox="0 0 24 24"><path d="M12 3.2a8.8 8.8 0 1 0 8.8 8.9 3 3 0 0 1-3.4-2.9 3 3 0 0 1-2.9-3.4A3 3 0 0 1 12 3.2Z"/><circle cx="9" cy="10" r="1.1"/><circle cx="14.6" cy="14.6" r="1.1"/><circle cx="9.4" cy="15.4" r="0.9"/></svg>
        </span>
        <p class="bar__text"><b>We use cookies</b> to keep Selvane fast and a little more personal.</p>
        <div class="bar__acts">
          <button class="btn btn--ghost" data-customize>Customize</button>
          <button class="btn btn--solid" data-accept>Accept all</button>
        </div>
      </div>

      <!-- the preferences card -->
      <div class="layer panel" data-panel aria-hidden="true">
        <header class="panel__head" data-reveal>
          <span class="tile" aria-hidden="true">
            <svg viewBox="0 0 24 24"><path d="M12 3.4 5 6v5.6c0 4.3 2.9 7.6 7 9 4.1-1.4 7-4.7 7-9V6Z"/><path class="tile__tick" d="m9 12.2 2.2 2.2 4-4.3"/></svg>
          </span>
          <div class="panel__titles">
            <h1 class="panel__title">Privacy preferences</h1>
            <p class="panel__sub">Choose what Selvane may store on this device.</p>
          </div>
          <button class="icon-btn" data-close aria-label="Close preferences">
            <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17"/></svg>
          </button>
        </header>

        <ul class="cats">
          <li class="cat is-locked" data-reveal>
            <div class="cat__row">
              <span class="cat__name">Essential<small>Sign in, cart, security</small></span>
              <span class="lock" aria-hidden="true"><svg viewBox="0 0 24 24"><rect x="6.5" y="11" width="11" height="8.4" rx="2"/><path d="M9 11V8.6a3 3 0 0 1 6 0V11"/></svg></span>
              <button class="switch is-on" role="switch" aria-checked="true" aria-disabled="true" aria-label="Essential, always on" data-switch="essential" disabled><span class="switch__fill"></span><i></i></button>
            </div>
          </li>
          <li class="cat" data-reveal data-cat="analytics">
            <div class="cat__row">
              <button class="cat__name cat__open" data-open aria-expanded="false" aria-controls="det-analytics">Analytics<small>How pages are read</small>
                <svg class="chev" viewBox="0 0 24 24" aria-hidden="true"><path d="m8 10 4 4 4-4"/></svg>
              </button>
              <button class="switch" role="switch" aria-checked="false" aria-label="Analytics" data-switch="analytics"><span class="switch__fill"></span><i></i></button>
            </div>
            <div class="cat__more" id="det-analytics" data-more>
              <p class="more__text" data-more-line>Counts visits and scroll depth, never who you are, so we know which pages to make faster.</p>
              <div class="chips" data-more-line>
                <span class="chip">First party</span>
                <span class="chip">Kept 13 months</span>
                <span class="chip">No ads</span>
              </div>
            </div>
          </li>
          <li class="cat" data-reveal>
            <div class="cat__row">
              <span class="cat__name">Personalisation<small>Remembers your picks</small></span>
              <button class="switch" role="switch" aria-checked="false" aria-label="Personalisation" data-switch="personal"><span class="switch__fill"></span><i></i></button>
            </div>
          </li>
          <li class="cat" data-reveal>
            <div class="cat__row">
              <span class="cat__name">Marketing<small>Offers on other sites</small></span>
              <button class="switch" role="switch" aria-checked="false" aria-label="Marketing" data-switch="marketing"><span class="switch__fill"></span><i></i></button>
            </div>
          </li>
        </ul>

        <footer class="panel__foot" data-reveal>
          <p class="count" aria-live="polite"><span class="count__num" data-count><span data-digit>1</span></span> of 4 on</p>
          <button class="btn btn--ghost" data-reject>Reject all</button>
          <button class="btn btn--solid" data-save>Save</button>
        </footer>
      </div>

      <!-- the confirmation pill -->
      <button class="layer pill" data-pill aria-hidden="true" tabindex="-1" aria-label="Cookie settings">
        <svg class="pill__check" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9" data-ring></circle><path d="m8 12.3 2.7 2.7 5.3-5.6" data-tick></path></svg>
        <span class="pill__text" data-pill-text>Preferences saved</span>
        <span class="pill__meta" data-pill-meta>3 of 4</span>
      </button>
    </section>
    <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.

39 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 “Cookie preferences” 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 black background, with a barely there warm amber light, Selvane’s cookie bar rises from the bottom, an invented site: an amber icon, «We use cookies to keep Selvane fast and a little more personal.» and two buttons, Customize and Accept all. A drawn pointer presses Customize: the bar’s words fade and the bar grows upwards into a card, first in width and then in height on a spring that takes it a little past and settles it, while a thread of light runs along the top edge; inside, the title «Privacy preferences», the four categories and the footer cascade in. Essential is on and locked; the pointer turns on Analytics, Personalisation and Marketing one after another: the knob slides and stretches on the way, the amber follows it filling the track, a thin halo passes around it and the number in «1 of 4 on» rolls up to 4. Then it taps Analytics: the chevron turns, below opens the line saying what it counts and three tags (First party, Kept 13 months, No ads), and the card rises with it. Marketing goes off again, the count drops to 3, and Save closes it all: the rows fade from the bottom, the card shrinks into a pill with a check drawing itself, «Preferences saved» widening on the wdth axis and «3 of 4», with a small jolt. Then the pill drops away and the loop starts again. It really works too: Accept all goes straight to the pill, Reject all turns the switches off in a row, the cross goes back to the bar, the pill reopens the preferences.

How it works

One shell, three layers

Bar, card and pill are three absolute layers inside the same shell, each laid out at its own fixed pixel width, so the text never rewraps while the shell changes size. The script measures the three layers and GSAP takes the shell’s width, height and borderRadius from one size to the next, with overflow hidden cutting what does not fit yet.

A spring in height

The shell keeps its bottom edge still and grows upwards: the width with power4.out, the height a moment longer with back.out, which takes it a few pixels past and settles it. Meanwhile a thread of light 46% wide runs along the top edge with keyframed opacity, and the card’s rows come in staggered by five hundredths.

A switch that fills

Inside the track an amber fill has its transformOrigin on the left: scaleX brings it behind the knob, which slides with back.out while widening by 32% on the side it is heading to, then comes back with elastic. A box-shadow that spreads and fades makes the halo, and the category name takes a step of a pixel and a half.

A category that opens

The Analytics detail goes from height 0 to auto, and with it the shell goes to the card’s height measured with the detail open, with the same duration and curve: the card seems to open by itself. The count is a drum one line high: the new digit comes in from below with yPercent while the old one leaves at the top.

The pill and the pilot

Save fades the rows from the bottom, then the shell shrinks to the pill’s width measured with max-content; the circle and the check draw with strokeDashoffset and the text goes from wdth 78 to 102. A timeline with repeatRefresh moves the drawn pointer reading the positions every time; at the first real touch it stops and starts again after eight seconds.

Values to change

NameFileDefaultWhat it changes
BRANDscript.jsSelvaneThe name of the invented site asking for consent, written in the bar and the card.
ACCENTscript.js#ffb547The colour of the switches that are on, the icons and the check.
MORPHscript.js0.75The seconds the bar takes to grow into the card and the card to fold into the pill.
SPRINGscript.js1.3How far the card goes past its height before settling; at 0 no bounce.
TOGGLE_GAPscript.js0.6The seconds between one switch and the next in the autopilot’s loop.
HOLDscript.js2.2The seconds the confirmation pill stays before the loop starts again.

Try them in the Playground

When to use it

For the cookie consent of any site: an online store, a blog, a portfolio, a product landing page, a hotel or restaurant site. It suits any time a bar at the bottom has to open into richer settings without a modal covering everything.

On phones

The bar goes onto two lines, with the buttons half wide each under the text; the card is as wide as the box minus the margins and the category rows are also measured on the height, so open with the Analytics detail it fits whole in the box. The shell keeps its bottom edge where the open card ends up in the middle. A tap does what a click does.

With reduced motion

No springs or slides: the shell fades out, takes its new size and fades back in; the switches change colour with a fade and the knob already in place, the detail opens without growing and the pill’s check is already drawn. The drawn pointer stays hidden.

Pitfalls

  • With a single container changing size the text rewrapped every frame and jittered: each layer has its own fixed pixel width, centred with margin auto, and the shell cuts it with overflow hidden.
  • The open card’s height with the detail is measured by setting the detail to height auto for a moment and reading offsetHeight, then putting it back: measured at the end of the detail’s tween, the card arrived late.
  • Save while the detail is open: first the detail closes and the rows fade, then the morph to the pill starts, with a «leaving» state in between so a second tap does not start two morphs.
  • On resize the sizes are pixels: the shell takes the size of its current state at once, and a morph halfway through is taken to its end.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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