---
title: "Popover"
description: "A small panel anchored to the button that opens it, closed by Escape or a press outside."
---

Use it for a few controls or a short explanation that belong to one button: notification settings for a channel, a filter, a confirmation that does not deserve a modal. For a list of actions use a [Dropdown Menu](/docs/components/dropdown), and for anything the reader must answer before going on use a [Modal](/docs/components/modal).

It is built on [Radix Popover](https://www.radix-ui.com/primitives/docs/components/popover) in React and [Reka UI Popover](https://reka-ui.com/docs/components/popover) in Vue. The panel opens below its trigger and start-aligned unless `side` and `align` say otherwise, and it flips when it would leave the viewport.

_Live example of Popover — see the page for the rendered demo._

## Installation

```bash
npx newtui@latest add popover
```

npm dependencies: React: radix-ui. Vue: reka-ui.

Files written — React: components/ui/popover.tsx. Vue: components/ui/popover/Popover.vue, components/ui/popover/PopoverAnchor.vue, components/ui/popover/PopoverTrigger.vue, components/ui/popover/PopoverContent.vue, components/ui/popover/index.ts.

## Usage

React:

```tsx
import { Popover } from "@/components/ui/popover"
```

Vue:

```ts
import { Popover, PopoverAnchor, PopoverTrigger, PopoverContent } from "@/components/ui/popover"
```

## API reference

**`Popover`**

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open / v-model:open` | `boolean` | — | Whether the panel is shown. In React, leave it undefined and pass `defaultOpen` to let the popover own it. |
| `onOpenChange` | `(open: boolean) => void` | — | React only. Called when the popover opens or closes; Vue emits `update:open`. |

**`PopoverContent`**

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `side` | `"top" \| "right" \| "bottom" \| "left"` | `"bottom"` | Which side of the trigger the panel opens on. It flips when there is no room. |
| `align` | `"start" \| "center" \| "end"` | `"start"` | Which edge of the trigger the panel lines up with. |
| `container` | `HTMLElement` | `document.body` | Element the panel is portalled into. Pass the enclosing native `<dialog>` or a themed wrapper to keep it there. |

`PopoverTrigger` is a plain button that carries the state and has no look of its own. Give it the classes of the button it should be (`buttonVariants({ variant: "secondary" })` in the example), or use `asChild` (`as-child` in Vue) to put the state on your own button. `PopoverAnchor` places the panel against another element than the trigger.

## Accessibility

The trigger carries `aria-expanded` and, while the panel is open, `aria-controls` pointing at it. The panel is a `role="dialog"` and needs a name: pass `aria-label` to `PopoverContent`, or `aria-labelledby` naming a heading inside it. Focus moves into the panel when it opens and returns to the trigger when it closes. `Escape` closes it, and so does a press anywhere outside. Inside a drawer or a modal, `Escape` closes the popover first and the dialog on the next press.

## Tokens

Popover reads its colours, radii and motion from the `--newt-*` tokens. Override a token rather than editing the component.
