Skip to content
animorio
IT
All components

Compress images button

Buttons, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 8.6 KBGSAP 28 KBFreeDownload the zip

The ‘Compress 3 images’ button of an image optimiser app, in dark ink on white with a mint light, like a Dribbble shot: on the left three drawn thumbnails between two thin jaws, in the middle the weight with a short bar, on the right a porcelain knob with two chevrons facing each other. Pressed, it compresses one image at a time: a line of light reads it, the jaws close, the thumbnail squashes and settles smaller, the weight rolls down from 12.6 to 3.1 MB and the bar shrinks. At the end the knob turns mint, a check draws itself and the label says how much was saved.

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>
<!--
  "Compress images button" 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 Compress images button with the file size that drops</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">
    <!-- the Compress images button of an image optimiser, in soft ink on white with a mint light. On the left three
         thumbnails of the images in a small fan between two thin jaws; on hover the fan opens and the chevrons in the
         knob pinch once. Pressed, the button compresses: a line of light reads each thumbnail, the jaws close on it,
         it squashes and settles a little smaller, while the weight rolls down and the bar beside it shrinks. At the
         end the chevrons become a check, the knob turns mint and the label says how much was saved -->
    <div class="ci" data-wrap>
      <span class="ci__floor" data-floor aria-hidden="true"></span>
      <button class="ci__btn" type="button" data-btn aria-label="Compress 3 images, 12.6 MB">
        <span class="ci__body" data-body>
          <span class="ci__skin" aria-hidden="true"></span>
          <span class="ci__shine" data-shine aria-hidden="true"></span>
          <span class="ci__sweep" aria-hidden="true"><span class="ci__sweep-band" data-sweep></span></span>
          <span class="ci__row">
            <span class="ci__press" aria-hidden="true">
              <span class="ci__jaw ci__jaw--l" data-jaw></span>
              <span class="ci__fan" data-fan>
                <span class="ci__thumb ci__thumb--c" data-thumb><span class="ci__scene"></span><span class="ci__scan" data-scan></span></span>
                <span class="ci__thumb ci__thumb--b" data-thumb><span class="ci__scene"></span><span class="ci__scan" data-scan></span></span>
                <span class="ci__thumb ci__thumb--a" data-thumb><span class="ci__scene"></span><span class="ci__scan" data-scan></span></span>
              </span>
              <span class="ci__jaw ci__jaw--r" data-jaw></span>
            </span>
            <span class="ci__text" aria-hidden="true">
              <span class="ci__labels">
                <span class="ci__label" data-label>Compress 3 images</span>
                <span class="ci__label" data-label>Compressing</span>
                <span class="ci__label" data-label>Saved 9.5 MB</span>
              </span>
              <span class="ci__meta">
                <span class="ci__weight"><span data-weight>12.6</span> MB</span>
                <span class="ci__bar"><span class="ci__bar-fill" data-bar></span></span>
                <span class="ci__note" data-note>PNG</span>
              </span>
            </span>
            <span class="ci__knob" data-knob aria-hidden="true">
              <span class="ci__well" data-well>
                <svg class="ci__icon" viewBox="0 0 20 20">
                  <path class="ci__chev" data-chev d="M3.6 6.2L7.4 10l-3.8 3.8"/>
                  <path class="ci__chev" data-chev d="M16.4 6.2L12.6 10l3.8 3.8"/>
                  <path class="ci__check" data-check pathLength="1" d="M5.2 10.4l3.2 3.2 6.6-7"/>
                </svg>
              </span>
            </span>
          </span>
        </span>
      </button>
    </div>
    <p class="sr" aria-live="polite" data-live></p>
  </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.

29 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 “Compress images button” 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, alone in the middle, there is a 60 pixel pill button in dark ink: the top edge catches the light in one pixel, the bottom stays in shadow, a very fine grain lies over it and a mint light glows in the lower left corner. On the left three thumbnails of the images in a fan between two thin jaws, each with its own drawn sky (peach, blue, sage), a white sun and two hills; in the middle ‘Compress 3 images’ and under it the weight, 12.6 MB, with a short bar and the PNG tag; on the right a porcelain knob with two chevrons pointing at each other. On hover the fan opens on a spring and leans toward the pointer, the jaws widen, a soft light follows the pointer and the chevrons pinch once. Pressed, the ink gives by a pixel and springs back, the thumbnails draw together and the compression starts, one image at a time: a line of mint light reads it left to right, the jaws light up mint and close, the thumbnail squashes and settles a little smaller, the chevrons in the knob pinch, the pill feels the press by a hair and the weight rolls down digit by digit while the bar shrinks; beside it ‘Image 1 of 3’, ‘Image 2 of 3’, ‘Image 3 of 3’. At the end the thumbnails square up into a small neat stack, the knob turns mint, the chevrons slide out to the sides and a check draws itself, a reflection crosses the pill and the label becomes ‘Saved 9.5 MB’, with ‘3.1 MB’ and ‘75% smaller’ in mint. Then everything goes back to rest. Left alone, the button goes round by itself.

How it works

An ink pill in layers

The button’s body is a single box with overflow hidden, moved only by GSAP (scale and y for the press, a 0.994 scaleX at every stroke of the press); inside, a layer with a feTurbulence grain in an SVG used as image, a mint radial-gradient in the corner and a vertical gradient, plus four inner shadows for the one pixel edges; above it a radial-gradient that follows the pointer through two CSS variables moved by gsap.quickTo.

Drawn thumbnails, not photos

Each thumbnail is a span with the sky colour in a CSS variable; its child draws the sun and two hills with four backgrounds (two hard-edged radial-gradients mixed with color-mix, the sun with its halo, the sky vertically) and an ::after makes the reflection. GSAP moves only x, y, rotation and scale between four poses: rest, open fan, tight while working, squared stack at the end.

One step per image

The compression is a timeline with one step per thumbnail: the line of light crosses the image by animating left in percent, the jaws come in with power3.in, the thumbnail goes to scaleX 0.8 and scaleY 1.06 and then settles at 0.92 on an elastic spring, while the two chevrons in the knob pinch by 1.8 pixels and come back.

The weight follows a single value

An object with a value from 0 to 1 moves in steps, a third per image (power1.in then power3.out, like a real job): from it come the megabytes with one decimal and the bar with scaleX from the left origin; at the end a mint layer of the bar lights up through a CSS variable animated by GSAP.

Success in the knob

The knob has a mint layer in ::before with its opacity in a CSS variable: GSAP takes it to 1, the two chevrons slide out to the sides, the check draws itself with pathLength 1 and strokeDashoffset and grows from 0.8 on a spring with svgOrigin at the centre; meanwhile a slanted reflection crosses the pill.

Values to change

NameFileDefaultWhat it changes
LABEL_RESTscript.jsCompress 3 imagesThe label at rest.
LABEL_BUSYscript.jsCompressingThe label while the images are compressed.
LABEL_DONEscript.jsSavedThe label at the end, followed by the megabytes saved.
FORMATscript.jsPNGThe format written beside the weight at rest.
SIZE_BEFOREscript.js12.6Megabytes before the compression.
SIZE_AFTERscript.js3.1Megabytes after the compression.
DURATIONscript.js3Seconds the compression of the three images takes.
SQUEEZEscript.js1How hard the jaws squash each thumbnail: 0 none, 2 a lot.
FANscript.js1How wide the fan of thumbnails opens on hover.
SPRINGscript.js1How springy the press and the thumbnails are: 0.4 calm, 2 very bouncy.
HOLDscript.js1.8Seconds the saved state stays before going back.
AUTOscript.jstrueGoes round by itself until someone touches it.

Try them in the Playground

When to use it

For an app or site that optimises images, a CMS, a photo editor, a developer tool or the panel of an online shop preparing product photos; it fits anywhere an action makes something lighter (backups, archives, videos). The weight rolling down shows at once how much is gained.

On phones

On the phone the button is at most 86% of the screen wide and the label shortens with an ellipsis if needed; there is no hover, so the light under the finger turns on at the touch and the compression, with the press and the weight rolling down, is the same.

With reduced motion

Nothing moves: the fan and the jaws stay still, the weight rolls down and the bar shrinks, the labels swap in place, the knob fades to mint and the check appears where the chevrons were.

Pitfalls

  • The final mint bar can’t be made by tweening background from a gradient to a colour (GSAP jumps): there is a mint layer over the fill, its opacity in a CSS variable animated by GSAP.
  • The jaws move with x from GSAP while their mint light comes from an ::after with a CSS transition tied to a class on the wrapper: one element for GSAP, the child for CSS.
  • Each thumbnail’s line of light must disappear inside the image and not over the pill: the thumbnail has overflow hidden and the line starts at minus three pixels.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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