🌐 Nodejs.cn

弹出窗口

在门户中显示丰富的内容,由按钮触发。

import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

安装

🌐 Installation

pnpm dlx shadcn@latest add popover

用法

🌐 Usage

import {
  Popover,
  PopoverContent,
  PopoverDescription,
  PopoverHeader,
  PopoverTitle,
  PopoverTrigger,
} from "@/components/ui/popover"
<Popover>
  <PopoverTrigger asChild>
    <Button variant="outline">Open Popover</Button>
  </PopoverTrigger>
  <PopoverContent>
    <PopoverHeader>
      <PopoverTitle>Title</PopoverTitle>
      <PopoverDescription>Description text here.</PopoverDescription>
    </PopoverHeader>
  </PopoverContent>
</Popover>

示例

🌐 Examples

基础

🌐 Basic

一个带有标题、标题和描述的简单弹出框。

🌐 A simple popover with a header, title, and description.

import { Button } from "@/components/ui/button"
import {
  Popover,

对齐

🌐 Align

PopoverContent 上使用 align 属性来控制水平对齐。

🌐 Use the align prop on PopoverContent to control the horizontal alignment.

import { Button } from "@/components/ui/button"
import {
  Popover,

有表格

🌐 With Form

一个里面有表单字段的弹出层。

🌐 A popover with form fields inside.

import { Button } from "@/components/ui/button"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"

从右到左

🌐 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 Popover 文档。

🌐 See the Radix UI Popover documentation.