Dialog
A dialog pauses the page so someone can finish one task. When they finish or close it, theyโre back where they started.
When to use it
Use a dialog when a task needs someoneโs full attention and has a clear end: renaming something, editing a few details, or filling in a short form. The page behind it dims and stops responding until the dialog closes.
If people need to see or use the page while they work, pick a different overlay. Start with one question: what should happen to the page behind it?
DialogThis page
The page waits.
A focused task with a clear end.
How it behaves
Base UI traps focus, locks background interaction, dismisses with Escape or an outside press, and restores focus to the trigger.
Always provide DialogTitle and DialogDescription. The close button has an accessible label.
Set showCloseButton={false} on DialogContent to supply your own close control. The preview puts a labeled ghost icon Button opposite the title.
Use render={<Button />} on triggers and close controls. Popups scroll within a constrained viewport on narrow screens.
DialogHeader and DialogFooter preserve the official composition API. DialogFooter accepts showCloseButton for a labeled closing action.
Build it
Add it with the shadcn CLI:
1pnpm dlx shadcn@latest add https://jzbui.com/r/dialog.jsonA complete example. Change the values to fit your product:
123456789101112131415161718192021import { X } from "lucide-react"import { Button } from "@/components/ui/button"import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"import { Dialog, DialogTrigger, DialogContent, DialogTitle, DialogDescription, DialogClose } from "@/components/ui/dialog"
<Dialog> <DialogTrigger render={<Button />}>Open dialog</DialogTrigger> <DialogContent showCloseButton={false}> <div className="flex items-center justify-between gap-4"> <DialogTitle className="min-w-0 pr-0">Project details</DialogTitle> <Tooltip> <TooltipTrigger render={<DialogClose aria-label="Close dialog" render={<Button variant="ghost" size="icon" />} />}> <X aria-hidden="true" /> </TooltipTrigger> <TooltipContent>Close dialog</TooltipContent> </Tooltip> </div> <DialogDescription>Review the project details before continuing.</DialogDescription> <DialogClose render={<Button variant="outline" />}>Done</DialogClose> </DialogContent></Dialog>The full source is yours to edit once installed: