Kinetic UI
Back to Introduction
Buttons

Morphing State Button

A button that fluidly morphs its physical shape during async operations, moving from a pill to a circle to a success checkmark.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add morphing-state-button
Morphing State Button

Morphing State Button

A production-ready micro-interaction button that physically morphs its layout during async operations.

Installation

npx kinetic-ui-cli@latest add morphing-state-button

How It Works

The MorphingStateButton uses framer-motion's magical layout prop. Instead of awkwardly swapping CSS classes, the component physically mathematically calculates the difference between its idle pill shape and its loading circular shape, and animates the width, height, and border-radius flawlessly. It also manages its own async state natively.

Usage Guide

1. Import the Component

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

import { MorphingStateButton } from "@/components/creative/morphing-state-button";

2. Implementation Example

Render the component and customize its behavior by passing props:

import { MorphingStateButton } from "@/components/creative/morphing-state-button";

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <MorphingStateButton
        onClick{/* value */}
        idleText="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.