
The colour columns
Hover, SVG
Six square keys on a very light grey, each with a line-drawn icon: when pressed, the icon’s strokes bend and move until they become its pair (menu becomes close, play becomes pause, moon becomes sun), on a short spring with a breath of bounce, while the key sinks and the state name below rewrites itself letter by letter.
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>
<!--
"Morphing icons" 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>Icons that morph into each other</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">
<!-- six icon keys: each icon is drawn with the same ten strokes, so pressing a key bends and moves the strokes of one
icon into the other (menu into close, play into pause, moon into sun) instead of swapping two pictures -->
<section class="board" data-board aria-label="Icon toggles">
<div class="grid" data-grid></div>
<p class="hint">Tap a key to switch its icon</p>
</section>
<svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.5 18.5 12 12.2 13.4 9.4 19.6Z"></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>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.
12 values to change
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 “Morphing icons” from Animorio and fit it into my siteEvery icon is made of ten strokes, and every stroke is a single Bézier curve: a start point, two control points, an end point and an opacity. Straight lines are curves with their controls at one and two thirds. A stroke an icon does not use is folded into a point with zero opacity, right where it will be born in the other icon: that is how the sun’s rays come out of the moon’s edge.
The change is a number p going from 0 to 1 (or 1 to 0) with GSAP and a back.out curve: every frame all the numbers of the ten strokes are mixed between the two icons by p and the d attribute is rewritten. With back.out p goes a little past 1 and comes back, so the strokes really bounce instead of fading.
Each pair has its own rotation (the menu turns 180 degrees, the moon minus 90) that grows with p. The stroke width rises by 22 percent halfway through with a sine on the progress, and the bell, when it switches off, also gets a shake made of four keyframes.
On press the key sinks to PRESS_DEPTH and its shadow tightens; released, it comes back with back.out(3). The name is split into letters: the old ones rise and leave 18 milliseconds apart, the new ones arrive from below on a small spring.
| Name | File | Default | What it changes |
|---|---|---|---|
STROKE | script.js | 1.8 | The thickness of the icon strokes. |
MORPH_TIME | script.js | 0.6 | The seconds the change from one icon to the other takes. |
OVERSHOOT | script.js | 1.7 | How far the strokes go past and come back (0 = no bounce). |
PRESS_DEPTH | script.js | 0.93 | How much the pressed key sinks (1 = not at all). |
AUTOPLAY_GAP | script.js | 0.7 | The seconds the fake pointer waits between one key and the next. |
ACCENT | script.js | '#4f46e5' | The colour of the switched-on icon and of the focus ring. |
For buttons that change state in an app or a site: the phone menu opening and closing, an audio or video player, an item to add to favourites, a finished download, notifications to mute, dark mode. The morphing icon tells what happened without having to read.
The same animation with adapted sizes: the keys are also measured on the screen height and the two rows of three always fit in the box. A tap does what a click does; the hover growth only happens with a mouse.
No bending strokes, no sinking keys and no pointer: the icon fades out and comes back already changed, and the name changes with a fade.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 5.1 KB; the libraries: GSAP 28 KB.
Tested on 25 October 2026
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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.