Skip to content
animorio
IT
Back to the library

Swatch wave recolour

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

The product photo on the page of a made-up shop, in the clean style of today’s products: a powder-coated steel bottle on a light table, with five colour swatches below. Pick a swatch and the new colour spreads over the bottle in a round wave that starts from the swatch itself, under the photo, while the shading, the highlight and the grain stay where they are; the colour name and the price change one after the other. Hover a swatch and its colour peeks over the edge of the photo first.

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>
<!--
  "Swatch wave recolour" 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>Corrin Field Bottle, colours</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>
  <!-- the product photo of a made-up shop. Pick a swatch and the new colour spreads over the bottle in a round wave
       that starts from the swatch itself; the shading, the highlight and the grain of the powder coat stay where they
       are. Hover a swatch and its colour peeks over the bottom edge of the photo first. -->
  <main class="stage">
    <article class="prodotto">
      <div class="foto" data-foto>
        <svg viewBox="0 0 300 360" role="img" aria-label="Field Bottle" data-svg>
          <defs>
            <radialGradient id="luceFondo" cx="0.28" cy="0.18" r="0.9">
              <stop offset="0" stop-color="#fff" stop-opacity=".85" />
              <stop offset=".55" stop-color="#fff" stop-opacity=".12" />
              <stop offset="1" stop-color="#fff" stop-opacity="0" />
            </radialGradient>
            <linearGradient id="piano" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#000" stop-opacity="0" />
              <stop offset=".02" stop-color="#000" stop-opacity=".05" />
              <stop offset="1" stop-color="#000" stop-opacity=".015" />
            </linearGradient>
            <linearGradient id="giro" x1="0" y1="0" x2="1" y2="0">
              <stop offset="0" stop-color="#000" stop-opacity=".34" />
              <stop offset=".13" stop-color="#000" stop-opacity=".07" />
              <stop offset=".25" stop-color="#fff" stop-opacity="0" />
              <stop offset=".305" stop-color="#fff" stop-opacity=".46" />
              <stop offset=".36" stop-color="#fff" stop-opacity=".04" />
              <stop offset=".6" stop-color="#000" stop-opacity="0" />
              <stop offset=".86" stop-color="#000" stop-opacity=".16" />
              <stop offset="1" stop-color="#000" stop-opacity=".36" />
            </linearGradient>
            <linearGradient id="piede" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#000" stop-opacity="0" />
              <stop offset="1" stop-color="#000" stop-opacity=".2" />
            </linearGradient>
            <linearGradient id="acciaio" x1="0" y1="0" x2="1" y2="0">
              <stop offset="0" stop-color="#8b8d90" />
              <stop offset=".3" stop-color="#e9eaeb" />
              <stop offset=".42" stop-color="#ffffff" />
              <stop offset=".7" stop-color="#b9bbbe" />
              <stop offset="1" stop-color="#6f7174" />
            </linearGradient>
            <linearGradient id="lampo" x1="0" y1="0" x2="1" y2="0">
              <stop offset="0" stop-color="#fff" stop-opacity="0" />
              <stop offset=".5" stop-color="#fff" stop-opacity=".55" />
              <stop offset="1" stop-color="#fff" stop-opacity="0" />
            </linearGradient>
            <filter id="sfuma" x="-50%" y="-200%" width="200%" height="500%"><feGaussianBlur stdDeviation="6" /></filter>
            <filter id="sfumaPoco" x="-50%" y="-200%" width="200%" height="500%"><feGaussianBlur stdDeviation="1.6" /></filter>
            <filter id="grana" x="0" y="0" width="100%" height="100%">
              <feTurbulence type="fractalNoise" baseFrequency="1.1" numOctaves="2" seed="7" />
              <feColorMatrix values="0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .45 -.16" />
            </filter>

            <!-- the coloured parts, drawn in currentColor so each layer can take its own colour -->
            <rect id="tinta" width="300" height="360" fill="currentColor" opacity=".075" />
            <g id="forma">
              <path d="M128 104 C113 108 104 120 104 140 L104 300 C104 312 112 320 124 320 L176 320 C188 320 196 312 196 300 L196 140 C196 120 187 108 172 104 Z" fill="currentColor" />
              <rect x="122" y="54" width="56" height="40" rx="9" fill="currentColor" />
              <path d="M137 56 C137 33 163 33 163 56" fill="none" stroke="currentColor" stroke-width="7" stroke-linecap="round" />
            </g>
            <clipPath id="soloCorpo">
              <path d="M128 104 C113 108 104 120 104 140 L104 300 C104 312 112 320 124 320 L176 320 C188 320 196 312 196 300 L196 140 C196 120 187 108 172 104 Z" />
            </clipPath>
            <clipPath id="soloTappo"><rect x="122" y="54" width="56" height="40" rx="9" /></clipPath>
            <clipPath id="onda"><circle data-cerchio cx="150" cy="400" r="0" /></clipPath>
            <clipPath id="sbirciata"><circle data-sbirciata cx="150" cy="400" r="0" /></clipPath>
          </defs>

          <rect width="300" height="360" fill="#f1eee9" />
          <rect width="300" height="360" fill="url(#luceFondo)" />
          <use href="#tinta" class="strato" data-base />
          <g clip-path="url(#onda)"><use href="#tinta" class="strato" data-nuovo /></g>
          <g clip-path="url(#sbirciata)"><use href="#tinta" class="strato strato--sbirciata" data-peek /></g>
          <rect y="298" width="300" height="62" fill="url(#piano)" />

          <g data-bottiglia>
            <g data-ombra>
              <ellipse cx="152" cy="321" rx="72" ry="9" fill="#000" opacity=".16" filter="url(#sfuma)" />
              <ellipse cx="150" cy="320" rx="46" ry="3.2" fill="#000" opacity=".34" filter="url(#sfumaPoco)" />
            </g>
            <use href="#forma" class="strato" data-base />
            <g clip-path="url(#onda)"><use href="#forma" class="strato" data-nuovo /></g>
            <g clip-path="url(#sbirciata)"><use href="#forma" class="strato" data-peek /></g>

            <!-- the shading stays still while the colour changes under it -->
            <g clip-path="url(#soloCorpo)">
              <rect x="104" y="100" width="92" height="222" fill="url(#giro)" />
              <rect x="104" y="270" width="92" height="52" fill="url(#piede)" />
              <rect x="104" y="100" width="92" height="222" filter="url(#grana)" />
              <rect data-lampo x="60" y="96" width="34" height="232" fill="url(#lampo)" transform="skewX(-14)" opacity="0" />
            </g>
            <g clip-path="url(#soloTappo)">
              <rect x="122" y="54" width="56" height="40" fill="url(#giro)" />
              <rect x="122" y="54" width="56" height="40" fill="#000" opacity=".16" />
              <rect x="122" y="54" width="56" height="40" filter="url(#grana)" />
            </g>
            <path d="M137 56 C137 33 163 33 163 56" fill="none" stroke="#fff" stroke-opacity=".28" stroke-width="1.4" stroke-linecap="round" transform="translate(-1.6 0)" />
            <rect x="126" y="92" width="48" height="13" rx="2" fill="url(#acciaio)" />
            <line x1="127" y1="97.5" x2="173" y2="97.5" stroke="#000" stroke-opacity=".14" stroke-width=".8" />
            <ellipse cx="129" cy="121" rx="9" ry="4.5" fill="#fff" opacity=".32" filter="url(#sfumaPoco)" transform="rotate(-28 129 121)" />
            <text x="150" y="232" text-anchor="middle" class="marchio-inciso">CORRIN</text>
            <line x1="141" y1="240" x2="159" y2="240" stroke="#fff" stroke-opacity=".38" stroke-width=".8" />
          </g>

          <circle data-filo cx="150" cy="400" r="0" fill="none" stroke="#fff" stroke-width="1.4" opacity="0" />
          <circle data-filo-sbirciata cx="150" cy="400" r="0" fill="none" stroke="#fff" stroke-width="1" opacity="0" />
        </svg>
      </div>

      <div class="info">
        <div class="riga">
          <h1 class="nome" data-nome>Field Bottle</h1>
          <span class="prezzo"><span data-prezzo>$38</span></span>
        </div>
        <div class="riga riga--sotto">
          <span class="colore"><span data-colore>Sage</span></span>
          <span class="dettaglio" data-dettaglio>750 ml, powder-coated steel</span>
        </div>
      </div>

      <div class="campioni" role="radiogroup" aria-label="Colour" data-campioni>
        <span class="anello" data-anello aria-hidden="true"></span>
      </div>
    </article>
  </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.

20 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 “Swatch wave recolour” 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 white background there is the product card of Corrin, a made-up brand: the photo of a powder-coated steel bottle standing on a light table with the light coming from the left, and below it the name, Field Bottle, the price, the colour and a line with the materials, then five round swatches: Sage, Clay, Ink, Sand and Ember. The bottle has a cap with a loop, a polished steel collar, a long highlight down its side, a shadow on the table and the brand engraved. Pick a swatch and the new colour spreads over the photo in a circle that starts from the swatch itself, under the photo, and rises until it covers everything: a thin white thread runs at the front of the wave and fades, and behind it the shading, the highlight and the grain of the paint stay, because only the colour changes. The background of the photo takes on a faint tint too. When the wave is halfway, the bottle gives a small nod up and comes back on a spring, the shadow narrows in answer, and a glint of light sweeps across the steel. The ring marking the chosen swatch slides to the new one with a bounce, the pressed swatch squashes and springs back, the colour name leaves upwards before the new one arrives, going from narrow to wide on the width axis of the typeface, and a moment later the price changes (Ember costs more). Hover a swatch and its colour peeks over the bottom edge of the photo with a rising arc; pick it and the wave starts again from there. If nobody touches it, the photo tries the colours by itself, one at a time.

How it works

Colour below, shading above

The coloured parts of the bottle are drawn only once in currentColor and called with use in three layers: the current one, the new one and the one that peeks. Shading, highlight, grain and brand sit on top, still: as the colour underneath changes, the light stays the same.

The wave starts at the swatch

The new layer is cut by a clipPath with a circle. Its centre is the pressed swatch, brought into the drawing’s coordinates with getBoundingClientRect: it sits below the photo, so the colour comes in from the edge as an arc. GSAP animates the radius out to the farthest corner, then the current layer takes the new colour and the circle goes back to zero.

The preview on hover

On hover a third layer, with its own circle, grows from the edge by PEEK units with back.out: the colour peeks in without covering yet. If that swatch is then picked, the wave starts from the preview’s radius instead of from zero.

One text at a time

The colour name and the price have one element each: the old one rises and blurs in two tenths, then the text changes and the new one comes from below with back.out and font-stretch from 78 to 100. So two words are never seen together.

Values to change

NameFileDefaultWhat it changes
PRODUCTscript.jsField BottleThe name of the product.
WAVE_TIMEscript.js1.05The seconds the colour takes to cover the photo.
PEEKscript.js74How far the colour peeks in when you hover a swatch.
SHINEscript.js1How bright the glint sweeping across the bottle is; 0 switches it off.
NODscript.js2.5How far the bottle lifts when the colour lands.
AUTOscript.js3.4The seconds between colours when nobody touches the photo.

Try them in the Playground

When to use it

For the page of a product that comes in several colours (bottles, mugs, backpacks, headphones, lamps, shoes), for an online shop’s product card or for the section of a landing page presenting the colour variants.

On phones

The same animation with adapted sizes: the photo is sized on the screen height, the swatches are big enough for a finger and the hover preview only appears with a mouse; with a finger you pick and the wave starts at once.

With reduced motion

No wave, nod or glint: the new colour fades in over the whole bottle and the name and price change in place.

Pitfalls

  • The clipPath circle lives in the drawing’s coordinates (300 by 360), not in pixels: its centre has to be recalculated from the swatch’s real position every time, because it changes with the window size.
  • The coloured parts have to be drawn in currentColor and called with use: each layer’s colour is given to the use, and the content inherits it.
  • The final radius is the distance from the swatch to the farthest corner of the photo, plus a few units: a fixed radius would leave a corner in the old colour.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 30 October 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