# Morphing Dialog

> Expand a card into a dialog by morphing its shape, image, and title into place.

Source: https://www.honestui.com/docs/animated/morphing-dialog

```tsx
"use client";

import {
  MorphingDialog,
  MorphingDialogClose,
  MorphingDialogContainer,
  MorphingDialogContent,
  MorphingDialogDescription,
  MorphingDialogImage,
  MorphingDialogSubtitle,
  MorphingDialogTitle,
  MorphingDialogTrigger,
} from "@/registry/default/animated/morphing-dialog";

export function MorphingDialogDemo() {
  return (
    <MorphingDialog>
      <MorphingDialogTrigger className="w-64">
        <MorphingDialogImage src="/ohio-stadium.jpg" alt="Ohio Stadium seen from the upper deck" className="h-40" />
        <div className="flex flex-col gap-0.5 p-3">
          <MorphingDialogTitle className="text-sm">Ohio Stadium</MorphingDialogTitle>
          <MorphingDialogSubtitle>Columbus, Ohio</MorphingDialogSubtitle>
        </div>
      </MorphingDialogTrigger>
      <MorphingDialogContainer>
        <MorphingDialogContent className="max-w-md">
          <MorphingDialogImage src="/ohio-stadium.jpg" alt="Ohio Stadium seen from the upper deck" className="h-64" />
          <div className="flex flex-col gap-0.5 p-5 pb-0">
            <MorphingDialogTitle className="text-lg">Ohio Stadium</MorphingDialogTitle>
            <MorphingDialogSubtitle>Columbus, Ohio</MorphingDialogSubtitle>
          </div>
          <MorphingDialogDescription className="flex flex-col gap-3 p-5">
            <p>
              Opened in 1922, the horseshoe-shaped stadium on the Olentangy River seats more than
              100,000 people, which makes it one of the largest in the world.
            </p>
            <p>
              The open south end was enclosed with permanent stands in 2001, and the field was
              lowered to add rows closer to play.
            </p>
          </MorphingDialogDescription>
          <MorphingDialogClose />
        </MorphingDialogContent>
      </MorphingDialogContainer>
    </MorphingDialog>
  );
}

```

## Overview [#overview]

Morphing Dialog turns a card into a full dialog without cutting away. The card's container, image, title, and subtitle carry shared layout ids, so each one springs from its place in the card to its place in the dialog, and back again on close. Body text that only exists in the dialog fades in after the morph settles. Use it for galleries, product cards, and previews where keeping the reader's place matters more than speed.

## Installation [#installation]

<CliBlock commands="[&#x22;morphing-dialog&#x22;]" />

## Usage [#usage]

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

<MorphingDialog>
  <MorphingDialogTrigger className="w-64">
    <MorphingDialogImage src="/cover.jpg" alt="" className="h-40" />
    <MorphingDialogTitle>Ohio Stadium</MorphingDialogTitle>
    <MorphingDialogSubtitle>Columbus, Ohio</MorphingDialogSubtitle>
  </MorphingDialogTrigger>
  <MorphingDialogContainer>
    <MorphingDialogContent>
      <MorphingDialogImage src="/cover.jpg" alt="" className="h-64" />
      <MorphingDialogTitle>Ohio Stadium</MorphingDialogTitle>
      <MorphingDialogSubtitle>Columbus, Ohio</MorphingDialogSubtitle>
      <MorphingDialogDescription>Opened in 1922…</MorphingDialogDescription>
      <MorphingDialogClose />
    </MorphingDialogContent>
  </MorphingDialogContainer>
</MorphingDialog>
```

Render the shared parts (`Image`, `Title`, `Subtitle`) once in the trigger and once in the content. Matching parts morph between the two; their sizes and positions can differ freely.

## Accessibility [#accessibility]

The trigger is a button that announces it opens a dialog. The open content is a modal dialog named by its `MorphingDialogTitle` and described by `MorphingDialogDescription`. Focus moves into the dialog when it opens, Tab and Shift+Tab stay inside it, and focus returns to the card when it closes. Escape, a click on the backdrop, and the close button all close it, and page scrolling is locked while it is open. With reduced motion enabled, the dialog fades in place instead of morphing from the card.

## API Reference [#api-reference]


  ### `open`

type: `boolean`

Controlled open state of 

    `MorphingDialog`

    .

  ### `defaultOpen`

type: `boolean` · default: `false`

Initial open state when uncontrolled.

  ### `onOpenChange`



void">
    Called when the dialog opens or closes.

  ### `transition`

type: `Transition` · default: `SPRING_LAYOUT`

Transition for the shared-element morph.

  ### `backdropClassName`

type: `string`

Classes for the backdrop, on 

    `MorphingDialogContainer`

    .

  ### `src / alt`

type: `string`

Image source and alternative text, on 

    `MorphingDialogImage`

    .

  ### `label`

type: `string` · default: `&#x22;Close&#x22;`

Accessible name of 

    `MorphingDialogClose`

     when it has no text.

  ### `style.borderRadius`

type: `number` · default: `12 / 16`

Corner radius of the trigger and content. Set it through 

    `style`

     so the radius stays correct during the morph.
