组件
- 手风琴 (Accordion)
- 警告 (Alert)
- 警告对话框 (Alert Dialog)
- 长宽比 (Aspect Ratio)
- 头像 (Avatar)
- 徽章 (Badge)
- 面包屑 (Breadcrumb)
- 按钮 (Button)
- 日历 (Calendar)
- 卡片 (Card)
- 轮播 (Carousel)
- 图表 (Chart)
- 复选框 (Checkbox)
- 可折叠 (Collapsible)
- 组合框 (Combobox)
- 命令 (Command)
- 上下文菜单 (Context Menu)
- 数据表格 (Data Table)
- 日期选择器 (Date Picker)
- 对话框 (Dialog)
- 抽屉 (Drawer)
- 下拉菜单 (Dropdown Menu)
- React Hook Form
- 悬停卡片 (Hover Card)
- 输入框 (Input)
- OTP 输入框 (Input OTP)
- 标签 (Label)
- 菜单栏 (Menubar)
- 导航菜单 (Navigation Menu)
- 分页 (Pagination)
- 气泡卡片 (Popover)
- 进度条 (Progress)
- 单选组 (Radio Group)
- 可调整大小 (Resizable)
- 滚动区域 (Scroll-area)
- 选择 (Select)
- 分隔线 (Separator)
- 侧边弹出层 (Sheet)
- 侧边栏 (Sidebar)
- 骨架屏 (Skeleton)
- 滑块 (Slider)
- Sonner
- 开关 (Switch)
- 表格 (Table)
- 选项卡 (Tabs)
- 文本域 (Textarea)
- 消息提示 (Toast)
- 切换 (Toggle)
- 切换组 (Toggle Group)
- 工具提示 (Tooltip)
- 排版 (Typography)
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover"
export function PopoverDemo() {
return (
<Popover>
<PopoverTrigger asChild>
<Button variant="outline">Open popover</Button>
</PopoverTrigger>
<PopoverContent className="w-80">
<div className="grid gap-4">
<div className="space-y-2">
<h4 className="leading-none font-medium">Dimensions</h4>
<p className="text-muted-foreground text-sm">
Set the dimensions for the layer.
</p>
</div>
<div className="grid gap-2">
<div className="grid grid-cols-3 items-center gap-4">
<Label htmlFor="width">Width</Label>
<Input
id="width"
defaultValue="100%"
className="col-span-2 h-8"
/>
</div>
<div className="grid grid-cols-3 items-center gap-4">
<Label htmlFor="maxWidth">Max. width</Label>
<Input
id="maxWidth"
defaultValue="300px"
className="col-span-2 h-8"
/>
</div>
<div className="grid grid-cols-3 items-center gap-4">
<Label htmlFor="height">Height</Label>
<Input
id="height"
defaultValue="25px"
className="col-span-2 h-8"
/>
</div>
<div className="grid grid-cols-3 items-center gap-4">
<Label htmlFor="maxHeight">Max. height</Label>
<Input
id="maxHeight"
defaultValue="none"
className="col-span-2 h-8"
/>
</div>
</div>
</div>
</PopoverContent>
</Popover>
)
}
安装
pnpm dlx shadcn@latest add popover
用法
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover"
<Popover>
<PopoverTrigger>Open</PopoverTrigger>
<PopoverContent>Place content for the popover here.</PopoverContent>
</Popover>