Fulldev UI

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

Installation

npx shadcn@latest add @fulldev/dialog

Usage

import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"
<Dialog>
  <DialogTrigger>Open</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Are you absolutely sure?</DialogTitle>
      <DialogDescription>
        This action cannot be undone. This will permanently delete your account
        and remove your data from our servers.
      </DialogDescription>
    </DialogHeader>
  </DialogContent>
</Dialog>

DialogTrigger and DialogClose render a Button and take its props, such as variant="outline". DialogContent moves to document.body while open, so a form around the whole dialog does not contain the content: put the form inside DialogContent when the dialog submits.

Composition

Dialog
├── DialogTrigger
└── DialogContent
    ├── DialogHeader
    │   ├── DialogTitle
    │   └── DialogDescription
    └── DialogFooter

Custom Close Button

Replace the default close control with your own DialogClose.

No Close Button

Use showCloseButton={false} to hide the close button.

Keep actions visible while the content scrolls.

Scrollable Content

Long content can scroll while the header stays in view.

RTL

Responsive activation

Pass a media query to Dialog to import and initialize its controller only while that query matches. Leaving the query destroys the controller and releases its portals and scroll lock. Returning initializes it again. A trigger click during the first download is performed once loading finishes, provided the query still matches.

The default has no breakpoint restriction. Keep the query and CSS visibility in the owning header block or site. Header blocks use fold="lg" by default and accept fold="xl"; that choice controls both visibility and activation.

API Reference

Source: src/components/ui/dialog

Dialog propTypeDefault
defaultOpenbooleanfalse
closeOnClickOutsidebooleantrue
closeOnEscapebooleantrue
lockScrollbooleantrue
alertDialogbooleanfalse
DialogContent propTypeDefault
showCloseButtonbooleantrue

Open or close a dialog from a script with root.dispatchEvent(new CustomEvent("dialog:set", { detail: { open: true } })) and listen for dialog:change. See the Data Slot docs for all events and data attributes.