Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Direction
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Menubar
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Typography
Get Started
import { Button } from "@/components/ui/button"
import {
Dialog,安装
pnpm dlx shadcn@latest add 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>示例
自定义关闭按钮
用你自己的按钮替换默认关闭控件。
import { Button } from "@/components/ui/button"
import {
Dialog,无关闭按钮
使用 showCloseButton={false} 隐藏关闭按钮。
import { Button } from "@/components/ui/button"
import {
Dialog,固定页脚
在内容滚动时保持操作按钮可见。
import { Button } from "@/components/ui/button"
import {
Dialog,可滚动内容
长内容可以滚动,而头部保持可见。
import { Button } from "@/components/ui/button"
import {
Dialog,RTL
要在 shadcn/ui 中启用 RTL 支持,请参见 RTL 配置指南。
"use client"
import { Button } from "@/examples/radix/ui-rtl/button"API 参考
更多信息请参见 Radix UI 文档。