Skip to content
animorio
IT
All components

Jacket colour picker

Pickers, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 9.0 KBGSAP 28 KBFreeDownload the zip

The product card of a made-up clothing label, Halden: a waxed cotton chore jacket hanging on its hook and, below, five fabric swatches cut with pinking shears, each with its own diagonal weave and stitching. Hover a swatch and it lifts; pick it and a ring slides over on a spring, stretching as it travels, the jacket takes the new colour with a sheen of light running across the cloth and sways on its hook, and the colour name rolls letter by letter, upwards going right and downwards going left.

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>
<!--
  "Jacket colour 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 jacket colour picker with woven fabric swatches and the rolling colour name</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>
    <!-- shared patterns: the twill weave, the corduroy of the collar, the light of a folded swatch -->
    <svg class="defs" width="0" height="0" aria-hidden="true" focusable="false">
      <defs>
        <pattern id="jk-twill" width="3" height="3" patternUnits="userSpaceOnUse" patternTransform="rotate(-38)">
          <rect width="3" height="1.05" fill="rgba(0,0,0,0.13)"/>
          <rect y="1.6" width="3" height="0.5" fill="rgba(255,255,255,0.08)"/>
        </pattern>
        <pattern id="jk-cord" width="2.4" height="4" patternUnits="userSpaceOnUse" patternTransform="rotate(52)">
          <rect width="1.1" height="4" fill="rgba(0,0,0,0.2)"/>
          <rect x="1.5" width="0.5" height="4" fill="rgba(255,255,255,0.1)"/>
        </pattern>
        <linearGradient id="jk-shade" x1="0" y1="0" x2="1" y2="0">
          <stop offset="0" stop-color="#fff" stop-opacity="0.16"/>
          <stop offset="0.42" stop-color="#fff" stop-opacity="0"/>
          <stop offset="0.7" stop-color="#000" stop-opacity="0.06"/>
          <stop offset="1" stop-color="#000" stop-opacity="0.26"/>
        </linearGradient>
        <linearGradient id="jk-drop" 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="0.14"/>
        </linearGradient>
        <linearGradient id="jk-sheen" x1="0" y1="0" x2="1" y2="0">
          <stop offset="0" stop-color="#fff" stop-opacity="0"/>
          <stop offset="0.5" stop-color="#fff" stop-opacity="0.42"/>
          <stop offset="1" stop-color="#fff" stop-opacity="0"/>
        </linearGradient>
        <linearGradient id="sw-fold" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0" stop-color="#fff" stop-opacity="0.22"/>
          <stop offset="0.46" stop-color="#fff" stop-opacity="0"/>
          <stop offset="0.54" stop-color="#000" stop-opacity="0.05"/>
          <stop offset="1" stop-color="#000" stop-opacity="0.24"/>
        </linearGradient>
        <clipPath id="sw-pink" clipPathUnits="userSpaceOnUse"><path data-pink d="M0 0H40V40H0Z"/></clipPath>
        <clipPath id="jk-clip">
          <path d="M60 42C48 46 42 56 40 70L28 156Q37 163 48 160L58 94Z"/>
          <path d="M140 42C152 46 158 56 160 70L172 156Q163 163 152 160L142 94Z"/>
          <path d="M60 42L84 33Q100 42 116 33L140 42L142 94L144 178Q100 185 56 178L58 94Z"/>
        </clipPath>
      </defs>
    </svg>

    <!-- the product card of Halden, an invented outerwear maker: the jacket on its hook and the colour picker -->
    <section class="jacket" data-jacket aria-labelledby="jk-title">
      <div class="jacket__hero" data-hero>
        <span class="jacket__wall" aria-hidden="true"></span>
        <span class="jacket__floor" aria-hidden="true" data-floor></span>
        <svg class="jacket__art" viewBox="0 0 200 200" aria-hidden="true" data-art>
          <path class="hook" d="M100 34V22C100 16 106 13 110 15.5C113.5 17.5 113 22.5 109.5 23.5" />
          <g class="garment" data-garment>
            <path class="hanger" d="M70 41.5L100 31.5L130 41.5" />
            <g clip-path="url(#jk-clip)">
              <rect width="200" height="200" class="cloth"/>
              <rect width="200" height="200" fill="url(#jk-twill)" opacity="0.55"/>
              <path class="fold" d="M58 94L56 178Q60 179 64 179.4L64 96Z"/>
              <path class="fold" d="M142 94L144 178Q140 179 136 179.4L136 96Z"/>
              <path class="fold fold--soft" d="M44 76Q41 120 34 154L40 155Q45 120 50 80Z"/>
              <path class="fold fold--soft" d="M156 76Q159 120 166 154L160 155Q155 120 150 80Z"/>
              <path class="seam" d="M58 94Q51 84 46 64M142 94Q149 84 154 64"/>
              <path class="cuff" d="M30.6 141Q39 146 50 143.6M169.4 141Q161 146 150 143.6"/>
              <path class="stitch" d="M31.2 145Q39 149.5 49.6 147.2M168.8 145Q161 149.5 150.4 147.2"/>
              <path class="stitch" d="M57 172.6Q100 179 143 172.6"/>
              <path class="placket" d="M100 46V182"/>
              <path class="stitch" d="M104 52V180"/>
              <g class="pockets">
                <path class="pocket" d="M68 70H90V93Q79 95.5 68 93Z"/>
                <path class="flap" d="M67 68H91V77Q79 79.5 67 77Z"/>
                <path class="pocket" d="M110 70H132V93Q121 95.5 110 93Z"/>
                <path class="flap" d="M109 68H133V77Q121 79.5 109 77Z"/>
                <path class="pocket" d="M64 122H93V151Q78.5 154 64 151Z"/>
                <path class="pocket" d="M107 122H136V151Q121.5 154 107 151Z"/>
                <path class="stitch" d="M66 124.6H91M109 124.6H134M69.6 79.6Q79 81.6 88.4 79.6M111.6 79.6Q121 81.6 130.4 79.6"/>
              </g>
              <g class="patch">
                <rect x="115" y="131" width="14" height="9" rx="1.6"/>
                <rect class="patch__stitch" x="116.4" y="132.4" width="11.2" height="6.2" rx="1"/>
                <path class="patch__mark" d="M119.6 134V138M124.4 134V138M119.6 136H124.4"/>
              </g>
              <rect width="200" height="200" fill="url(#jk-shade)"/>
              <rect width="200" height="200" fill="url(#jk-drop)"/>
              <rect class="sheen" data-sheen x="-70" y="0" width="54" height="200" fill="url(#jk-sheen)"/>
            </g>
            <g class="collar">
              <path class="collar__band" d="M84 33Q100 42 116 33L116.6 36.4Q100 46 83.4 36.4Z"/>
              <path class="collar__leaf" d="M84 34L100 50L91 63L75 41Z"/>
              <path class="collar__leaf" d="M116 34L100 50L109 63L125 41Z"/>
              <path class="collar__cord" d="M84 34L100 50L91 63L75 41Z"/>
              <path class="collar__cord" d="M116 34L100 50L109 63L125 41Z"/>
              <path class="stitch stitch--collar" d="M78.4 41.6L90.6 59.4M121.6 41.6L109.4 59.4"/>
            </g>
            <g class="buttons">
              <circle cx="100" cy="70" r="2.7"/><circle cx="100" cy="95" r="2.7"/><circle cx="100" cy="120" r="2.7"/><circle cx="100" cy="145" r="2.7"/><circle cx="100" cy="168" r="2.7"/>
              <circle cx="79" cy="74.6" r="1.7"/><circle cx="121" cy="74.6" r="1.7"/>
            </g>
          </g>
        </svg>
        <span class="jacket__badge">Waxed twill</span>
      </div>

      <div class="jacket__info">
        <div class="jacket__titles">
          <span class="jacket__brand">Halden</span>
          <h2 class="jacket__name" id="jk-title">Field Chore Jacket</h2>
        </div>
        <span class="jacket__price">&euro;248</span>
      </div>

      <div class="jacket__colour">
        <span class="jacket__label" id="jk-colour">Colour</span>
        <span class="roll" data-roll aria-live="polite"></span>
        <span class="jacket__stock" data-stock></span>
      </div>

      <div class="swatches" role="radiogroup" aria-labelledby="jk-colour" data-swatches>
        <span class="swatches__ring" data-ring aria-hidden="true"></span>
      </div>
    </section>

    <svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2L18.6 12.4L12.2 13.6L9 19.4Z"/></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.

22 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 “Jacket colour 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

A warm white card with the jacket hanging on its hook at the top, on a backdrop tinted with its colour, with fine grain and a shadow on the floor; below, the label, the jacket's name, the price, the colour line and five fabric swatches. The swatch under the pointer lifts and leans a little on a spring and its shadow grows; pressed, it squashes and comes back. Pick a colour and the dark ring slides onto the swatch, stretching in the direction it travels, and settles with a pixel of bounce; the jacket, the corduroy collar, the stitching and the backdrop change colour together while a blade of light runs across the cloth, the jacket swings on its hook and comes to rest, and the name rolls letter by letter while the stock line changes («Only 3 left» in brick red). Left alone, a drawn pointer walks through every colour and back to moss.

How it works

The jacket in one SVG

Sleeves and body sit in a clipPath: inside, a rectangle in the jacket's colour, the diagonal weave (a pattern rotated by -38 degrees with one dark and one light line), the folds, the dashed stitching, the pockets, the leather patch, the left-to-right shading and the blade of light. The collar carries a second ribbed pattern, like corduroy.

The colour in four variables

Every part of the jacket takes its colour from var(--c), var(--c-dark), var(--c-stitch) and var(--c-tint): picking a swatch, GSAP tweens the four :root variables to the new colour in COLOUR_TIME seconds, and jacket, collar, stitching and backdrop change together.

Swatches cut with pinking shears

The script draws the pinking shears edge (ten teeth a side) into a shared clipPath; each swatch is an SVG with the same weave pattern, the light of a fold and the stitching, turned by a degree or two. The swatch under the pointer rises LIFT pixels with back.out and comes back with elastic.out.

The ring that stretches

The ring is a single absolutely positioned element: it goes to the new swatch with back.out(RING_SPRING) while a small timeline stretches it by STRETCH from the side it leaves and brings it back with elastic.out. The sizes come from offsetLeft and offsetWidth, read again on resize.

The rolling name

Each name is a row of inline-block letters: the old ones leave upwards and the new ones come in from below with back.out and ROLL_STAGGER between letters (the other way round going left, starting from the last letter), while the width of the line goes to the new name's.

The sway on the hook and the pilot

The jacket turns around its hook (svgOrigin 100 22), starting SWAY degrees against the direction of the change, and comes to rest with elastic.out; the floor shadow follows. The pilot is a timeline that takes the drawn pointer to each swatch, hovers, presses and waits HOLD seconds; at the first real mouse move, tap or key it stops.

Values to change

NameFileDefaultWhat it changes
RING_SPRINGscript.js1.6How far the ring overshoots the swatch it lands on (0 none).
RING_TIMEscript.js0.55Seconds for the ring to slide to the new swatch.
STRETCHscript.js0.35How much the ring stretches as it travels (0 none).
ROLL_STAGGERscript.js0.035Seconds between one letter of the name and the next.
SWAYscript.js3.2Degrees the jacket swings on its hook when the colour changes.
LIFTscript.js4Pixels a swatch rises under the pointer.
COLOUR_TIMEscript.js0.7Seconds for the jacket to take the new colour.
HOLDscript.js1.5Seconds the pilot stays on each colour.
SPEEDscript.js1Pilot speed.
LOOPscript.jstrueThe pilot starts over.

Try them in the Playground

When to use it

On the product page of a clothing, shoe, bag or furniture shop: wherever a colour or fabric variant is picked and the product should take it at once, without loading a new photo. It also works in a configurator or in a catalogue card.

On phones

The same animation with adapted sizes: the card is 90% of the screen wide, the jacket and the swatches also follow the window height (vh), so everything fits the phone box. On tap the swatch squashes and lifts as on hover.

With reduced motion

Nothing moves: the jacket's colour changes as a fade, the ring jumps to the chosen swatch, the name swaps as a fade and the pilot's pointer is hidden.

Pitfalls

  • The weave patterns live in a zero-sized but visible definitions SVG: with display none Chrome stops drawing the patterns and gradients used by the other SVGs.
  • The sway goes on the jacket group with svgOrigin in drawing coordinates (the hook, 100 22): with a percentage transformOrigin the jacket turned around its own centre and came off the hook.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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