SVG Morph Button

Button with SVG path morph animation. Supports custom paths for idle, hover, loading, success.

Last updated Mar 5, 2026

Component

Installation

pnpm dlx shadcn@latest add "https://pulkitxm.com/components/svg-morph-button.json"

Usage

Import

Add the SvgMorphButton import.

import { SvgMorphButton } from "@/components/svg-morph-button";

Use

Use with children. Click to see loading → success morph.

<SvgMorphButton>Submit</SvgMorphButton>;

Guidelines

  • Default paths: plus (idle), x (hover), circle (loading), check (success).
  • Pass customPaths to override. Keys: idle, hover, loading, success.
  • morphDuration controls animation speed.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
classNamestringAdditional CSS classes.
customPathsPartial<Record<string, string>>Custom paths for idle, hover, loading, success.
morphDurationnumber0.35Morph animation duration in seconds.
idleLabelstring"Click me"Label when idle.
loadingLabelstring"Loading..."Label during loading state.
successLabelstring"Done!"Label when success.

Examples

Basic

Default button with plus → loading → check morph.

import { SvgMorphButton } from "@/components/svg-morph-button";

<SvgMorphButton>
  <span>Submit</span>
</SvgMorphButton>;

Custom paths

Custom SVG paths for each state.

import { SvgMorphButton } from "@/components/svg-morph-button";

const paths = {
  idle: "M12 2 L14 2 L14 10 L22 10 L22 12 L14 12 L14 22 L12 22 Z",
  hover: "M12 4 L20 12 L12 20 L4 12 Z",
  loading: "M12 4 A8 8 0 0 1 20 12 A8 8 0 0 1 12 20 Z",
  success: "M5 12 L10 17 L19 6 Z",
};

<SvgMorphButton customPaths={paths}>
  <span>Custom</span>
</SvgMorphButton>;

Made with ❤️ by Pulkit & Cursor :)

© 2026 Pulkit. All rights reserved

DMCA Verified

Last updated: