dialog
A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
Installation
npx @gentleduck/cli add dialog
npx @gentleduck/cli add dialog
Usage
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"import {
Dialog,
DialogContent,
DialogDescription,
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><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>Examples
Controlled Dialog
Notes
To use the Dialog component from within a Context Menu or Dropdown Menu, you must encase the Context Menu or
Dropdown Menu component in the Dialog component.
<Dialog>
<ContextMenu>
<ContextMenuTrigger>Right click</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem>Open</ContextMenuItem>
<ContextMenuItem>Download</ContextMenuItem>
<DialogTrigger asChild>
<ContextMenuItem>
<span>Delete</span>
</ContextMenuItem>
</DialogTrigger>
</ContextMenuContent>
</ContextMenu>
<DialogContent>
<DialogHeader>
<DialogTitle>Are you absolutely sure?</DialogTitle>
<DialogDescription>
This action cannot be undone. Are you sure you want to permanently
delete this file from our servers?
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button type="submit">Confirm</Button>
</DialogFooter>
</DialogContent>
</Dialog><Dialog>
<ContextMenu>
<ContextMenuTrigger>Right click</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem>Open</ContextMenuItem>
<ContextMenuItem>Download</ContextMenuItem>
<DialogTrigger asChild>
<ContextMenuItem>
<span>Delete</span>
</ContextMenuItem>
</DialogTrigger>
</ContextMenuContent>
</ContextMenu>
<DialogContent>
<DialogHeader>
<DialogTitle>Are you absolutely sure?</DialogTitle>
<DialogDescription>
This action cannot be undone. Are you sure you want to permanently
delete this file from our servers?
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button type="submit">Confirm</Button>
</DialogFooter>
</DialogContent>
</Dialog>API Reference
Dialog
closeButton(boolean, optional): Whether to display a close button. Default:true....props(DialogPrimitive.Rootprops): All props supported byDialogPrimitive.Root.
DialogTrigger
children(React.ReactNode): Content to render inside the trigger button....props(Omit<DialogPrimitive.Trigger, 'size' | 'asChild'> & Omit<Button, 'asChild'>): Props from bothDialogPrimitive.TriggerandButtoncomponents.
DialogCloseX
size(number, optional): Icon size in pixels. Default:16.children(React.ReactNode, optional): Custom content instead of the default<X />icon....props(React.HTMLProps<HTMLButtonElement>): Native button props.
DialogContent
renderOnce(boolean, optional): Whether to render the content only once. Default:false.overlay(string, optional): Overlay animation variant. Default:'default'.closedby(string, optional): How the dialog can be closed. Default:'any'.animation(string, optional): Dialog animation style. Default:'default'.className(string, optional): Additional class names.children(React.ReactNode): Dialog inner content....props(DialogContentProps): All props fromDialogContentProps.
DialogHeader
className(string, optional): Additional class names....props(React.HTMLProps<HTMLDivElement>): Nativedivelement props.
DialogFooter
className(string, optional): Additional class names....props(React.HTMLProps<HTMLDivElement>): Nativedivelement props.
DialogTitle
className(string, optional): Additional class names....props(React.HTMLProps<HTMLHeadingElement>): Native heading element props.
DialogDescription
className(string, optional): Additional class names....props(React.HTMLProps<HTMLParagraphElement>): Native paragraph element props.
DialogClose
- Alias of:
DialogTrigger.