Back to Devoured - August 21, 2026
DEVOURED
Morph Any SVG Icon Into Any Other (Website)

Morph Any SVG Icon Into Any Other (Website)

Design Morphicons
Morphicons uses closed-form 2D Procrustes math to animate any two SVG icons into one another without manual keyframe configuration.
What: Created for React, Vue, Svelte, Astro, and React Native, Morphicons takes two stroke icons as data and calculates an optimal animation path between them using spring physics and a 6.5KB engine.
Why it matters: This offloads complex icon animation logic from manual CSS or design-tool exports to a pure-code runtime calculation.
Takeaway: Install via `npm install morphicons` and import `MorphIcon` in your project to handle transitions between any SVG icon set (e.g., Lucide, Heroicons, or Tabler).
Deep dive
  • Solves icon similarity using 2D Procrustes analysis to determine optimal rotation.
  • Operates entirely in memory, avoiding DOM manipulation.
  • Works with any icon set conforming to a standard coordinate grid.
  • Zero runtime dependencies and small footprint.
Decoder
  • 2D Procrustes analysis: A statistical method used to find the optimal rotation and alignment between two shapes to minimize the distance between their points.
Original article

Morph any SVG icon into any other.

Animate Lucide, Tabler, Heroicons or any stroke icon set. Optimal rotation solved in closed form, spring physics, zero dependencies.

Click an icon to add it to your set. Icons from different libraries morph into each other: they all share the 24×24 grid.

import { MorphIcon } from "morphicons/react";
import { Menu, X } from "lucide"; // data, not components

<button onClick={() => setOpen(o => !o)} aria-expanded={open}>
  <MorphIcon icon={open ? X : Menu} />
</button>

That is the whole thing — in React, Vue, Svelte, React Native or Astro (no island needed: the icon upgrades to a web component). No wrappers, no keys, no from/to pairs, no configuration. Swap the pair for any two icons above.

Six kilobytes of math.

morphicons solves the optimal similarity between two shapes in closed form (2D Procrustes): if a pair is congruent under rotation, it rotates; if not, it morphs in the aligned frame. Nobody declares rotation groups by hand. Springs are interruptible, corners stay sharp at rest, and the core never touches the DOM, so React, Vue, Svelte, React Native, Astro, Next.js and plain JavaScript are all first-class drivers.

Icons are consumed as data, not components: a d attribute or Lucide’s IconNode format, structurally typed. No adapters, no per-library setup.

core, gzipped, everything included
6.5 KB
runtime dependencies
0
to plan any morph pair
<1 ms
shared rAF for every icon on screen
1

Works with any stroke icon set — on any grid, via fitIcon.

  • Lucide
  • Tabler
  • Heroicons outline
  • Iconoir
  • Akar
  • Untitled UI
  • Hugeicons
  • shadcn registry
Explore all 58 articles in today's digest

Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi