---
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, 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.
- Also called: modal or popup.

## When not to use

- For a panel from the edge use Sheet, for a list's record RecordPeek.

## 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/trail-dialog
```

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

## Usage

```tsx
import {
  Dialog, DialogTrigger, DialogPortal, DialogClose, DialogOverlay, DialogContent, DialogHeader, DialogHeaderActions, DialogTitle, DialogDescription, DialogBody, DialogTitleBox, DialogDescriptionBox,
  DialogToolbar, DialogFooter, DialogFooterGroup, DialogFooterEnd,
} from '@/components/ui/goop/dialog';
import { Button } from '@/components/ui/goop/button';

<Dialog>
  <DialogTrigger asChild>
    <Button variant="outline">Archive list</Button>
  </DialogTrigger>
  <DialogContent size="xs">
    <DialogHeader closeLabel="Close">
      <DialogTitle>Archive this list?</DialogTitle>
    </DialogHeader>
    <DialogBody>
      <DialogDescription>Its 12 notes move to the archive, and you can bring the list back from there.</DialogDescription>
    </DialogBody>
    <DialogFooter>
      <DialogFooterEnd>
        <DialogClose asChild>
          <Button variant="outline">Cancel</Button>
        </DialogClose>
        <Button>Archive list</Button>
      </DialogFooterEnd>
    </DialogFooter>
  </DialogContent>
</Dialog>
```

- Fits: list, settings: overlay.
- height, width, padding, gap, corner, border, background, shadow, 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-focus-visible, data-state=closed

### Parts

- `DialogTrigger` — Wraps the control that opens the dialog; put the theme's Button inside with asChild; 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 backdrop 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 row; put the DialogTitle in it, with any chips or actions before the close; its props: dialog--header.md
- `DialogHeaderActions` — The header's actions, 12 px after its content and 6 px apart (in the window 2 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 (description, fields, text), between its header and footer
- `DialogTitleBox` — The boxes a one-line field sits in at the body's top (the caller's field, the theme's `TextInput`)
- `DialogDescriptionBox` — The boxes a many-line field sits in under it (the caller's field, the theme's `Textarea`)
- `DialogToolbar` — A row of controls under the body (property chips, a round button)
- `DialogFooter` — The dialog's bottom row for its buttons; put them in DialogFooterEnd, the main action last
- `DialogFooterGroup` — The footer's group at its start (an attach button)
- `DialogFooterEnd` — The footer's end, growing, its controls at the end 12 px apart (the main action the last)

- Required: DialogTitle, inside DialogContent

### 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, md (default), 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 6 px apart (in the window 2 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 row; put the DialogTitle in it, with any chips or actions before the close.

```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).

## Accessibility

- The behaviour layer under the part answers keys, focus and dismissal: never write your own.
- focus-visible: the attribute data-focus-visible
- expanded: the attribute data-state=closed
- open: the attribute data-state=closed

## 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.

## Related

- [Sheet](/themes/trail/components/sheet): A panel that slides in from an edge of the window over the page, for filters, a form or a record's details.
- [Record peek](/themes/trail/components/record-peek): A list whose open record shows in a panel over its end, for a quick look without leaving the list.
- [Button](/themes/trail/components/button): A button with words that runs an action, in several looks and sizes.
- [Alert dialog](/themes/trail/components/alert-dialog): A modal that asks a person to confirm or cancel before an action that cannot be undone, such as a delete.
