Mark Yo

Morphing Modal

Component

About

A multi-step modal that resizes and blur-crossfades its panel content when you switch views, anchored to the bottom like a sheet or centered on screen.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Morphing Modal to your project and fits it to your theme.

Code

How Morphing Modal is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { MorphingModal } from "@/components/ui/morphing-modal";
import { useState } from "react";

type View = "profile" | "plan" | "confirm";

export default function MorphingModalDemo() {
  const [viewId, setViewId] = useState<View | null>(null);

  return (
    <div className="flex min-h-[400px] w-full items-center justify-center">
      <button
        type="button"
        onClick={() => setViewId("profile")}
        className="rounded-full bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground"
      >
        Open modal
      </button>

      <MorphingModal viewId={viewId} onClose={() => setViewId(null)}>
        {viewId === "profile" && (
          <div className="space-y-4">
            <h2 className="text-lg font-semibold">Your profile</h2>
            <p className="text-sm text-muted-foreground">
              Review your details before continuing.
            </p>
            <button
              type="button"
              onClick={() => setViewId("plan")}
              className="w-full rounded-xl bg-primary py-2.5 text-sm font-medium text-primary-foreground"
            >
              Continue
            </button>
          </div>
        )}

        {viewId === "plan" && (
          <div className="space-y-4">
            <h2 className="text-lg font-semibold">Choose a plan</h2>
            <p className="text-sm text-muted-foreground">
              Pick the plan that fits you best.
            </p>
            <button
              type="button"
              onClick={() => setViewId("confirm")}
              className="w-full rounded-xl bg-primary py-2.5 text-sm font-medium text-primary-foreground"
            >
              Continue
            </button>
          </div>
        )}

        {viewId === "confirm" && (
          <div className="space-y-4">
            <h2 className="text-lg font-semibold">All set</h2>
            <p className="text-sm text-muted-foreground">
              Your changes have been saved.
            </p>
            <button
              type="button"
              onClick={() => setViewId(null)}
              className="w-full rounded-xl bg-primary py-2.5 text-sm font-medium text-primary-foreground"
            >
              Done
            </button>
          </div>
        )}
      </MorphingModal>
    </div>
  );
}

Dependencies

More by Mark Yo

View all
  • Loader

    Loader

    64
  • Pricing Table

    Pricing Table

    23
  • Bento Grid

    Bento Grid

    1
  • Expandable Tabs

    Expandable Tabs

    1
  • Stateful Button

    Stateful Button

  • Animated Button

    Animated Button

  • Morph Popover

    Morph Popover

  • Kbd

    Kbd