GooseUI

Components

Morphing Dialog

New

A dialog that morphs out of its card through the native View Transitions API. The dialog itself is a native <dialog> opened by an invoker button, so it opens and closes even before hydration or without JavaScript. The script (about 1.7 kB, no libraries) only adds the morph. Closes with Escape, a click outside or the close button.

Browser Support

Limited availability
8 features
Details
<dialog>

Displays the modal dialog

Your browser:
View transitions

Animates the change between views

Your browser:
Invoker commands

Controls the dialog with buttons

Your browser:
@starting-style

Animates the initial appearance

Your browser:
<dialog closedby>

Controls how the dialog closes

Your browser:
:has()

Locks page scrolling while open

Your browser:
::backdrop

Styles the dialog backdrop

Your browser:
transition-behavior

Animates the dialog closing

Your browser:

Preview

Click on the card to open the dialog with a morphing animation.

Mountain landscape

Swiss Alps

Explore the majestic mountains

The Swiss Alps are a mountain range in Switzerland, forming a portion of the Alps. They are located in the Swiss Plateau and the Jura Mountains region. The highest peak is the Dufourspitze at 4,634 meters. The Alps are a popular destination for skiing, hiking, and mountaineering.

Installation

npx shadcn@latest add @gooseui/morphing-dialog
pnpm dlx shadcn@latest add @gooseui/morphing-dialog
yarn dlx shadcn@latest add @gooseui/morphing-dialog
bunx --bun shadcn@latest add @gooseui/morphing-dialog

Usage

import {
  MorphingDialog,
  MorphingDialogTrigger,
  MorphingDialogContainer,
  MorphingDialogContent,
  MorphingDialogImage,
  MorphingDialogTitle,
  MorphingDialogSubtitle,
  MorphingDialogDescription,
  MorphingDialogClose,
} from "@/components/ui/morphing-dialog"

export default function Example() {
  return (
    <MorphingDialog>
      <MorphingDialogTrigger>
        <MorphingDialogImage src="/image.jpg" alt="..." />
        <MorphingDialogTitle>Title</MorphingDialogTitle>
        <MorphingDialogSubtitle>Subtitle</MorphingDialogSubtitle>
      </MorphingDialogTrigger>

      <MorphingDialogContainer>
        <MorphingDialogContent>
          <MorphingDialogClose />
          <MorphingDialogImage src="/image.jpg" alt="..." />
          <MorphingDialogTitle>Title</MorphingDialogTitle>
          <MorphingDialogSubtitle>Subtitle</MorphingDialogSubtitle>
          <MorphingDialogDescription>
            Full description here...
          </MorphingDialogDescription>
        </MorphingDialogContent>
      </MorphingDialogContainer>
    </MorphingDialog>
  )
}

Examples

Profile Card

Use with profile cards for a smooth expansion effect

Profile

John Doe

Software Engineer at Acme Inc.

John is a passionate software engineer with over 10 years of experience in building web applications. He specializes in React, TypeScript, and Node.js. When not coding, he enjoys hiking and photography.

Components

ComponentDescription
MorphingDialogRoot component, manages state
MorphingDialogTriggerButton that opens the dialog (commandfor + command="show-modal")
MorphingDialogContainerNative <dialog> with a backdrop
MorphingDialogContentDialog content wrapper
MorphingDialogImageImage (<img> with object-cover)
MorphingDialogTitleTitle (h2)
MorphingDialogSubtitleSubtitle
MorphingDialogDescriptionDescription content
MorphingDialogCloseClose button (X icon)

Features

  • Native View Transitions API — no external animation libraries
  • Click-outside to close — click backdrop to dismiss
  • Escape key support — keyboard accessible
  • Focus trap — native modal, the page behind is inert
  • Body scroll lock — prevents background scrolling
  • Progressive enhancement — opens without JavaScript, without the morph in older browsers
  • Reduced motion support — respects prefers-reduced-motion