Morph Icon

MorphIcon is an animated SVG icon that cycles through an array of SVG path strings and smoothly morphs the path shape between them at a fixed interval, such as play to pause. It is a client component built on motion's SVG primitives.

Morph Icon
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @animbits/icons-morph

Requires @animbits in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { MorphIcon } from "@/components/animations/icons/morph";export function Example() {  return (    <MorphIcon      paths={["M8 5v14l11-7z", "M6 5h4v14H6zM14 5h4v14h-4z"]}      className="size-8 text-foreground"    />  );}
  • Showing a state toggle icon that should visibly transform, such as play to pause or menu to close, inside buttons or player controls
  • Adding a lively, attention-grabbing decorative icon to a hero section, feature card, or navigation item
  • Cycling through a small set of related glyphs (for example, sync, check, alert) to indicate ongoing status
  • Replacing static icons where a subtle continuous morph communicates motion without requiring user interaction

Examples

Play / pause morph

Two-state icon that morphs between a play triangle and pause bars every 2 seconds.

play-/-pause-morph.tsx
import { MorphIcon } from "@/components/animations/icons/morph";const PLAY_PAUSE = [  "M8 5v14l11-7z",  "M6 5h4v14H6zM14 5h4v14h-4z",];export function PlayPauseIcon() {  return <MorphIcon paths={PLAY_PAUSE} className="size-6 text-primary" />;}

Faster morph with custom color

Shortens the interval and transition duration and uses a custom stroke color and width.

faster-morph-with-custom-color.tsx
import { MorphIcon } from "@/components/animations/icons/morph";const STATUS = [  "M4 12a8 8 0 1 0 16 0a8 8 0 1 0-16 0",  "M5 12l4 4 10-10",];export function StatusIcon() {  return (    <MorphIcon      paths={STATUS}      interval={1}      duration={0.5}      strokeColor="#22c55e"      strokeWidth={3}      className="size-10"    />  );}

Icon inside a button

Uses the morphing icon as a decorative element next to a label inside a button.

icon-inside-a-button.tsx
import { MorphIcon } from "@/components/animations/icons/morph";const MENU_CLOSE = [  "M4 6h16M4 12h16M4 18h16",  "M6 6l12 12M6 18L18 6",];export function MenuButton() {  return (    <button type="button" className="inline-flex items-center gap-2 rounded-md border px-3 py-2">      <MorphIcon paths={MENU_CLOSE} aria-hidden="true" className="size-4" />      Menu    </button>  );}

API reference

PropTypeDefaultDescription
pathsstring[]—Required. Array of SVG path d-strings to cycle through. The component advances to the next path on every interval, wrapping back to the first.
durationnumber0.3Transition duration in seconds for the path morph animation (applied with easeInOut).
intervalnumber2Time in seconds between morph steps. Converted internally to milliseconds for setInterval.
strokeColorstring"currentColor"Value applied to the SVG stroke attribute.
strokeWidthnumber2Value applied to the SVG strokeWidth attribute.
classNamestring—Class names applied to the root svg element (merged with cn).
...propsOmit<SVGMotionProps<SVGSVGElement>, "children">—All other motion-enhanced SVG props (for example aria-hidden, style, width, height, viewBox, onClick) are forwarded to the root svg. children is not accepted.
Dependency notestring—The source imports from framer-motion/client and motion/react, while registry dependencies list motion. Ensure framer-motion is available in the project if the import fails.

Accessibility

  • The root element is an svg with no title or role; when the icon is purely decorative, pass aria-hidden="true" as shown in the examples.
  • If the icon conveys meaning (for example play or pause state), wrap it in a button with an accessible name via aria-label, since the morph alone is not announced to assistive technology.
  • Respect prefers-reduced-motion by avoiding continuous morphing for users who request reduced motion, or by increasing interval and reducing duration.
  • Ensure sufficient contrast of the stroke color against its background, since the default currentColor inherits from surrounding text.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Morph Icon" component (animbits/icons-morph) from its shadcn registry.1. Install it with: npx shadcn@latest add @animbits/icons-morph2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: paths, duration, interval, strokeColor, strokeWidth, className, ...props, Dependency note.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { MorphIcon } from "@/components/animations/icons/morph";export function Example() {  return (    <MorphIcon      paths={["M8 5v14l11-7z", "M6 5h4v14H6zM14 5h4v14h-4z"]}      className="size-8 text-foreground"    />  );}```

Files & dependencies

  • registry/new-york/animations/icons/morph.tsx
dependenciesmotion

Looks similar, elsewhere