Popover

Displays rich content in a portal, triggered by a button.

Demo

Dark previewReplay previewOpen in new tab

Usage

Import the parts you need from the component's folder.

ts
import {
  Popover,
  PopoverContent,
  PopoverDescription,
  PopoverHeader,
  PopoverTitle,
  PopoverTrigger,
} from "@/components/ui/popover";

Basic

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

Dark previewReplay previewOpen in new tab

Align

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

Dark previewReplay previewOpen in new tab

With Form

A popover with form fields inside.

Dark previewReplay previewOpen in new tab

API Reference

Popover

PropTypeDefaultDescription
openboolean—Open state. Supports v-model:open.
defaultOpenbooleanfalseOpen state when initially rendered. Use when the popover is uncontrolled.
modalbooleanfalseTrap focus and dim background.
EventDescription
update:openFires when the popover opens or closes. Enables v-model:open.

PopoverTrigger

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto the child element instead of a button.

PopoverAnchor

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto the child element. Positions the content against this element instead of the trigger.

PopoverContent

PropTypeDefaultDescription
side"top" | "right" | "bottom" | "left""bottom"Anchor side.
align"start" | "center" | "end""center"Alignment along the side.
sideOffsetnumber4Gap from the trigger.

PopoverHeader

PropTypeDefaultDescription
classstring—Extra classes, merged with cn(). Wraps the title and description.

PopoverTitle

PropTypeDefaultDescription
classstring—Extra classes, merged with cn(). Renders an h4.

PopoverDescription

PropTypeDefaultDescription
classstring—Extra classes, merged with cn(). Renders a muted paragraph.

Accessibility

Keyboard shortcuts and ARIA behavior.

Shortcut Description
SpaceWhen focus is on the trigger, toggles the popover open or closed.
EnterWhen focus is on the trigger, toggles the popover open or closed.
TabMoves through focusable elements inside the content, then out of the popover.
Shift + TabMoves focus to the previous focusable element.
EscCloses the popover and returns focus to the trigger.
  • Focus moves into the content when the popover opens.
  • The trigger exposes aria-expanded and aria-controls linking it to the content.