Dialog

A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.

Demo

Dark previewReplay previewOpen in new tab

Usage

Import the parts you need from the component's folder.

ts
import {
  Dialog,
  DialogTrigger,
  DialogPortal,
  DialogContent,
  DialogClose,
  DialogHeader,
  DialogFooter,
  DialogTitle,
  DialogDescription,
  DialogOverlay,
  DialogScrollContent,
} from "@/components/ui/dialog";

Close Button

Use DialogClose to render a custom close button, for example in the footer.

Dark previewReplay previewOpen in new tab

No Close Button

Set showCloseButton to false to hide the default close button in the top-right corner.

Dark previewReplay previewOpen in new tab

Scrollable Content

Constrain the body with max-height and overflow-y-auto for long content.

Dark previewReplay previewOpen in new tab

API Reference

Dialog

PropTypeDefaultDescription
openboolean—Open state. Supports v-model:open.
modalbooleantrueBlock interaction with the rest of the page while open.
EventDescription
update:openFires when the dialog opens or closes.

DialogContent

PropTypeDefaultDescription
showCloseButtonbooleantrueShow the ✕ button in the top-right corner.
classstring—Extra classes, e.g. sm:max-w-sm for width.

DialogFooter

PropTypeDefaultDescription
showCloseButtonbooleanfalseRender a built-in outline Close button.

DialogTrigger / DialogClose

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto the child element (e.g. a Button).

Accessibility

Keyboard shortcuts and ARIA behavior.

Shortcut Description
EscCloses the dialog.
TabFocus is trapped inside the dialog while open.