# Dialog

Host: Base UI. Path: transitions. Preset: `scale-fade`. Built against [@base-ui/react 1.5.0](https://www.npmjs.com/package/@base-ui/react/v/1.5.0).

Close and reopen part way through the exit. The transition picks up from where it was.

The page this file mirrors mounts the component twice, once with the attribute and once without, so the only difference between the two is the library.

Upstream documentation: [Base UI documentation](https://base-ui.com/react/components/dialog)

The same component in other hosts: [Radix UI](/radix/dialog.md), [No library](/native/dialog.md).

## Where the attribute goes

The parts this demo composes, and the value each one carries. Everything inside an animated part is that part's content, so the tree stops there.

```text
Dialog.Root
  Dialog.Trigger
  Dialog.Portal
    Dialog.Backdrop  data-motion="fade"
    Dialog.Popup  data-motion="scale-fade"
```

## How the match works

| Step | Value |
| --- | --- |
| host writes | `data-open / data-closed, plus data-ending-style` |
| easeful matches | `[data-motion~="scale-fade"][data-ending-style]` |
| what runs | `transition: opacity, scale 150ms` |
| you write | `<Dialog.Popup data-motion="scale-fade" />` |

## Every value that works here

Every value the manifest allows on this host, single presets and the pairs that compose. The first is what this component ships with. Both stages are the same component, so anything that changes between them is the attribute.

| Value | Link |
| --- | --- |
| `scale-fade` | the default |
| `fade` | [fade](/base-ui/dialog#motion=fade) |
| `slide-up` | [slide-up](/base-ui/dialog#motion=slide-up) |
| `fade slide-up` | [fade slide-up](/base-ui/dialog#motion=fade%20slide-up) |
| `scale-fade slide-up` | [scale-fade slide-up](/base-ui/dialog#motion=scale-fade%20slide-up) |

## Source

`apps/docs/components/demos/base-ui/dialog.tsx`

```tsx
"use client"

import { Dialog } from "@base-ui/react/dialog"
import type { DemoProps } from "@/components/demos/props"

export function BaseUiDialog({ motion }: DemoProps) {
  return (
    <Dialog.Root>
      <Dialog.Trigger className="btn">Open dialog</Dialog.Trigger>
      <Dialog.Portal>
        <Dialog.Backdrop className="scrim" data-motion={motion && "fade"} />
        <Dialog.Popup className="modal" data-motion={motion}>
          <Dialog.Title className="panel__title">Publish this release</Dialog.Title>
          <Dialog.Description className="panel__body">
            Close it and reopen part way through the exit. The transition picks up from where it
            was rather than jumping back to the start.
          </Dialog.Description>
          <div className="modal__actions">
            <Dialog.Close className="btn btn--primary">Publish</Dialog.Close>
            <Dialog.Close className="btn">Cancel</Dialog.Close>
          </div>
        </Dialog.Popup>
      </Dialog.Portal>
    </Dialog.Root>
  )
}
```
