Shape-aware icon morphing

Change the icon name. shapcn animates the rest.

Any icon morphs into any other. shapcn rigs the shapes first, so parts move in order instead of every point sliding at once.
Lucide, Tabler, Phosphor, Remix, Hugeicons or your own icons.

80 KB engine, gzipped. 170 KB with all 1,858 Lucide icons.

Examples

Playground

No more sloptweening

Point-to-point tweenEvery point slides to a point, all at once.
Shape-aware rigRigged first. Parts move in order.

How it works

shapcn
    t = 0.00
    1 of 6

    Each shape gets a weight.

    Weight is the length of a stroke. A closed shape counts 1.5 times. Strokes at half of the largest weight or more are the body. The rest are parts.

    2 of 6

    The rig.

    Before it moves anything, shapcn rigs the icon, as an animator parents layers.

    • The heaviest shapes are the root: the body.
    • A part belongs to the shape it touches. The antenna belongs to the head. The head belongs to the body.
    • The rig sets the order. Deepest parts leave first and arrive last. Mirror parts move together.
    3 of 6

    What morphs?

    The root of the rig becomes the root. The body becomes the body. A part ties to a part only when they are alike.

    4 of 6

    What moves?

    Each part rides on its parent. A part with no partner goes into the body. A new part grows out of the edge it connects to. Nothing melts or fades.

    5 of 6

    A twin slides out.

    A twin starts at half size behind its twin and slides out. Mirror parts in the rig move together.

    6 of 6

    When?

    The rig sets the order. Old parts go in, deepest first: antennae into the head, then the head into the body. The body changes. New parts grow out in reverse order, deepest last.

    Usage

    80 KBengine, gzipped170 KB with all Lucide icons

    What you download

    Icons you do not import are not downloaded (npm).

    In your code

    <morph-icon name="sun"></morph-icon>el.setAttribute('name', 'moon') // later
    <head> Added: <script type="module" src="https://shapcn.com/morph-icon.js"></script> </head> <button id="theme"> Removed: <svg viewBox="0 0 24 24">...sun...</svg> Added: <morph-icon name="sun"></morph-icon> </button> <script> theme.onclick = () => { dark = !dark; Removed: theme.innerHTML = dark ? MOON_SVG : SUN_SVG; Added: theme.firstElementChild.name = dark ? 'moon' : 'sun'; }; </script>
    The result

    Install

    One script tag, or npm. Source is on GitHub.

    Any site<script type="module" src="https://shapcn.com/morph-icon.js"></script> <morph-icon name="menu"></morph-icon>
    npmnpm i shape-aware-morph
    shadcn/uinpx shadcn@latest add https://shapcn.com/r/morph-icon.json
    Build from the source: github.com/seahorsecastle/shapcngit clone https://github.com/seahorsecastle/shapcn cd shapcn/package npm install && npm run buildThen use dist/morph-icon.js, or import from the package folder.
    Bring my UI to lifeBring my UI to life with shapcn. Follow https://shapcn.com/agents

    Paste this into Claude Code, Cursor or Codex. What the agent reads.

    Also a Chrome extension that plays these motions on the icons of any site. About it.