GitHub Stars

Dialog

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 { Button } from "@/components/ui/button"
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>
    <DialogFooter>
      <DialogClose variant="outline">Cancel</DialogClose>
      <Button>Continue</Button>
    </DialogFooter>
  </DialogContent>
</Dialog>

Composition

Use the following composition to build a Dialog:

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

Examples

With Form

Replace the default close control with your own button.

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.

API Reference

See the GitHub source code for more information on props. See the data-slot docs for more information on interactivity.