mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-02 17:08:39 +00:00
61 lines
1.2 KiB
Plaintext
61 lines
1.2 KiB
Plaintext
---
|
|
title: Popover
|
|
description: Displays rich content in a portal, triggered by a button.
|
|
component: true
|
|
radix:
|
|
link: https://www.radix-ui.com/docs/primitives/components/popover
|
|
api: https://www.radix-ui.com/docs/primitives/components/popover#api-reference
|
|
---
|
|
|
|
<ComponentExample src="/components/examples/popover/demo.tsx">
|
|
<PopoverDemo />
|
|
</ComponentExample>
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
npx shadcn-ui add popover
|
|
```
|
|
|
|
<Accordion type="single" collapsible>
|
|
<AccordionItem value="manual-installation">
|
|
<AccordionTrigger>Manual Installation</AccordionTrigger>
|
|
<AccordionContent>
|
|
|
|
1. Install the `@radix-ui/react-popover` component from radix-ui:
|
|
|
|
```bash
|
|
npm install @radix-ui/react-popover
|
|
```
|
|
|
|
2. Copy and paste the following code into your project.
|
|
|
|
<ComponentSource src="/components/ui/popover.tsx" />
|
|
|
|
<Callout>
|
|
This is the `<Popover />` primitive. You can place it in a file at
|
|
`components/ui/popover.tsx`.
|
|
</Callout>
|
|
|
|
</AccordionContent>
|
|
|
|
</AccordionItem>
|
|
</Accordion>
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import {
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
} from "@/components/ui/popover"
|
|
```
|
|
|
|
```tsx
|
|
<Popover>
|
|
<PopoverTrigger>Open</PopoverTrigger>
|
|
<PopoverContent>Place content for the popover here.</PopoverContent>
|
|
</Popover>
|
|
```
|