---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Dialog

A window over the page for one focused task, such as a short form or a question to confirm, for React and Tailwind CSS. Free, MIT.

Free. Its export: `Dialog`.

## Try it

Press "Archive list": the dialog asks first. Archive list is busy for a moment and the list shows archived, with Bring back beside it. Cancel, Escape, the cross or a click outside leave it as it was; the focus comes back to the button (after an archive, to Bring back).

The archive is a timer; the list lives in the page only.

## When to use

- A window over the page for one focused task, such as a short form or a question to confirm.
- Also called: modal or popup.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Dialog on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.

```sh
npx shadcn@4.23.1 add @goop/meadow-dialog
```

```text
Add the Goop Dialog to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { DialogPortal, DialogOverlay, DialogHeaderActions, DialogTitleBox, DialogDescriptionBox, DialogToolbar, DialogFooterGroup } from '@/components/ui/goop/dialog';

import { Button } from '@/components/ui/goop/button';
import {
  Dialog,
  DialogBody,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogFooterEnd,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from '@/components/ui/goop/dialog';

function ArchiveList({ onArchive }: { onArchive: () => void }) {
  return (
    <Dialog>
      <DialogTrigger asChild>
        <Button variant="outline">Archive list</Button>
      </DialogTrigger>
      <DialogContent size="xs">
        <DialogHeader>
          <DialogTitle>Archive this list?</DialogTitle>
        </DialogHeader>
        <DialogBody>
          <DialogDescription>Its 12 notes move to the archive, where the crew can restore them.</DialogDescription>
        </DialogBody>
        <DialogFooter>
          <DialogFooterEnd>
            <DialogClose asChild>
              <Button variant="ghost">Cancel</Button>
            </DialogClose>
            <DialogClose asChild>
              <Button onClick={onArchive}>Archive list</Button>
            </DialogClose>
          </DialogFooterEnd>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}
```

- Fits: list, settings: overlay.
- height, width, padding, gap, corner, border, background, text, motion: add no class for these.

## API reference

### Options

- `open?: boolean`
- `defaultOpen?: boolean = false`
- `onOpenChange?: (open: boolean) => void`
- `modal?: boolean = true`

- State: open (open / defaultOpen / onOpenChange); drawn by data-state=open

### Parts

- `DialogTrigger` — Wraps the control that opens the dialog; also takes asChild?: boolean
- `DialogPortal` — Where the layer is drawn
- `DialogClose` — Wraps a control that closes the dialog, such as a Cancel button in the footer; also takes asChild?: boolean
- `DialogOverlay` — The dimmed page behind a modal dialog; DialogContent draws it, so add none yourself
- `DialogContent` — The scrim, the positioner and the panel, in a portal — the end of `<body>`, or `container`; its props: dialog--content.md
- `DialogHeader` — The dialog's top; put the DialogTitle in it, with any chips or actions before the close, and a field after the title; its props: dialog--header.md
- `DialogHeaderActions` — The header's actions, 12 px after its content and 4 px apart; its props: dialog--header-actions.md
- `DialogTitle` — The dialog's name, which every dialog needs; put it in the DialogHeader
- `DialogDescription` — A line that says what the dialog is for, read out with its title; put it in DialogBody
- `DialogBody` — The dialog's main content (a description, fields, sections of rows), between its header and footer
- `DialogDescriptionBox` — The boxes a many-line field sits in under it (the caller's field, the theme's `Textarea`, which grows with its words from one row), for a form a caller builds
- `DialogFooter` — The dialog's bottom row for its buttons; put them in DialogFooterEnd, the main action last, and what stands apart (a link to copy, a quiet button) in DialogFooterGroup at its start
- `DialogFooterGroup` — The footer's group at its start (a quiet button, a switch)
- `DialogFooterEnd` — The footer's end, growing, its controls at the end 8 px apart (the main action the last)

- Required: DialogTitle, inside DialogContent
- DialogTitleBox
- DialogToolbar

### DialogContent

The scrim, the positioner and the panel, in a portal — the end of `<body>`, or `container`.

```tsx
import { DialogContent } from '@/components/ui/goop/dialog';
```

### Options

- variant: default (default), window
- size: xs, sm (default), md, lg, full
- container?: HTMLElement | null — Where the layer is portalled; the end of `<body>` when left out.

### DialogHeaderActions

The header's actions, 12 px after its content and 4 px apart.

```tsx
import { DialogHeaderActions } from '@/components/ui/goop/dialog';
```

### Options

- closable?: boolean = true — Draw the default close button last (true); false when the caller's children hold their own, or none is wanted.
- closeLabel?: string = 'Close' — The default close button's accessible name.

### DialogHeader

The dialog's top; put the DialogTitle in it, with any chips or actions before the close, and a field after the title.

```tsx
import { DialogHeader } from '@/components/ui/goop/dialog';
```

### Options

- actions?: ReactNode — Round quiet buttons before the close button (the theme's `IconButton` ghost); unused beside a composed holder.
- closeLabel?: string = 'Close' — The close button's accessible name (the shorthand's; a composed holder takes its own).

## Keyboard

- Enter: on the trigger: open, the focus on the panel's first control
- Space: on the trigger: open, the focus on the panel's first control
- Tab / Shift+Tab: cycle the focus through the panel's controls, never out of it (the window: walk out in the page's order)

## Accessibility

- The behaviour layer under the part answers keys, focus and dismissal: never write your own.

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

Shortened to fit: the data-slot values; what else went is in agent/ship/manifest.json.

## Related

- [Button](/themes/meadow/components/button): A button with words that runs an action, in several looks and sizes, on a page, in a row or in a sidebar.
- [Alert dialog](/themes/meadow/components/alert-dialog): A modal that asks a person to confirm or cancel before an action that cannot be undone, such as a delete.
- [Sheet](/themes/meadow/components/sheet): A panel that comes in along an edge of the window over the page, for a record's details, a form or filters.
- [Popover](/themes/meadow/components/popover): A small panel that opens from its button and floats over the page, which stays usable under it.
