Kinetic UI
Back to Introduction
Media

SVG Shape Morph

A component that physically morphs between two SVG paths using vector interpolation.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add svg-shape-morph
SVG Shape Morph

SVG Shape Morphing

Click the icon to see a buttery-smooth vector shape morph between a Play and Pause state.

Installation

npx kinetic-ui-cli@latest add svg-shape-morph

How It Works

Morphing SVGs is notoriously tricky because you usually have to interpolate between two drastically different mathematical paths. The SvgShapeMorph component utilizes framer-motion's native SVG path interpolation. By ensuring that pathA and pathB possess the exact same structure (the same number of M and L plotting commands), Framer Motion is able to Tween between the point coordinates flawlessly, allowing a "Play" icon to organically reshape into a "Pause" icon.

Usage Guide

1. Import the Component

Import the component into your React or Next.js page:

import { SvgShapeMorph } from "@/components/creative/svg-shape-morph";

2. Implementation Example

Render the component and customize its behavior by passing props:

import { SvgShapeMorph } from "@/components/creative/svg-shape-morph";

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <SvgShapeMorph
        pathA="example"
        pathB="example"
        fill="example"
      />
    </div>
  );
}
Performance Notes
  • Uses CSS hardware acceleration via GPU transform-binds.
  • Damped interpolation minimizes paint-redraw flashes.
  • Tree-shakable import: only compiles elements requested.
Accessibility Notes
  • Full keyboard focus-ring navigation support (`Tab`/`Shift+Tab`).
  • ARIA roles mapped correctly for assistive screen readers.
  • Respects `prefers-reduced-motion` system toggles.