组件
import { Button } from "@/components/ui/button"
import {
Dialog,安装
🌐 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
用你自己的按钮替换默认的关闭控件。
🌐 Replace the default close control with your own button.
import { Button } from "@/components/ui/button"
import {
Dialog,没有关闭按钮
🌐 No Close Button
使用 showCloseButton={false} 来隐藏关闭按钮。
🌐 Use showCloseButton={false} to hide the close button.
import { Button } from "@/components/ui/button"
import {
Dialog,固定底部
🌐 Sticky Footer
在内容滚动时保持操作可见。
🌐 Keep actions visible while the content scrolls.
import { Button } from "@/components/ui/button"
import {
Dialog,可滚动内容
🌐 Scrollable Content
长内容可以滚动,而标题保持可见。
🌐 Long content can scroll while the header stays in view.
import { Button } from "@/components/ui/button"
import {
Dialog,从右到左
🌐 RTL
要在 shadcn/ui 中启用 RTL 支持,请参阅 RTL 配置指南。
🌐 To enable RTL support in shadcn/ui, see the RTL configuration guide.
"use client"
import { Button } from "@/examples/radix/ui-rtl/button"API参考
🌐 API Reference
有关更多信息,请参阅 Radix UI 文档。
🌐 See the Radix UI documentation for more information.