Docs
对话框
对话框
覆盖在主窗口或另一个对话框窗口上的窗口,使下面的内容无效。
安装
¥Installation
pnpm dlx shadcn@latest add dialog
用法
¥Usage
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>
示例
¥Examples
自定义关闭按钮
¥Custom close button
注释
¥Notes
要从 Context Menu
或 Dropdown Menu
中激活 Dialog
组件,必须将 Context Menu
或 Dropdown Menu
组件装入 Dialog
组件中。有关更多信息,请参阅链接问题 此处。
¥To activate 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. For more information, refer to the linked issue here.
<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>