Skip to content
shadcn.io
shadcn.io is not affiliated with official shadcn/ui

Shadcn Popover for React and Tailwind

Overlay with extra info or options on trigger.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/popover.json

Anatomy

Popover
├── PopoverTrigger
└── PopoverContent
    ├── PopoverHeader
    │   ├── PopoverTitle
    │   └── PopoverDescription
    ├── PopoverBody
    ├── PopoverFooter
    └── PopoverClose

Usage

import { 
  Popover, 
  PopoverTrigger, 
  PopoverContent, 
  PopoverHeader,
  PopoverTitle, 
  PopoverDescription,
  PopoverBody,
  PopoverFooter,
  PopoverClose,
} from "@/components/ui/popover";
<Popover>
  <PopoverTrigger />
  <PopoverContent>
    <PopoverHeader>
      <PopoverTitle />
      <PopoverDescription />
    </PopoverHeader>
    <PopoverBody>
      {/* Your content here */}
    </PopoverBody>
    <PopoverFooter>
      <PopoverClose />
    </PopoverFooter>
  </PopoverContent>
</Popover>

Controlled

Use open and onOpenChange on the root to control the popover state.

Positioning

Control the position of the popover relative to the trigger using the positioning prop.

Title & Description

PopoverHeader supports two usage patterns:

Using props

Pass title and description props directly to PopoverHeader.

<PopoverHeader title="Popover Title" description="Popover description" />

This approach does not require PopoverTitle or PopoverDescription components.

Using components

Use PopoverTitle and PopoverDescription as children for more control.

<PopoverHeader>
  <PopoverTitle>Popover Title</PopoverTitle>
  <PopoverDescription>Popover description</PopoverDescription>
</PopoverHeader>

Examples

Non-modal

To make the popover non-modal, set the modal prop to false.

Nested

Nest popovers within one another.

Anchor

Use PopoverAnchor to position the popover relative to a different element than the trigger.

Close button

Use showCloseButton prop to show a close button in the top-right corner.

Close behavior

Use closeOnInteractOutside and closeOnEscape props to prevent closing on outside click and escape.

Scrollable

Use PopoverBody to make the content area scrollable while keeping header and footer fixed.

Inside dialog

Render a popover inside a dialog.

Custom spacing

Use [--space:--spacing("value")] on PopoverContent to adjust internal padding.

Default spacing is --spacing(4).

You can use breakpoint utilities to change the internal spacing at different screen sizes.

  md:[--space:--spacing(6)] lg:[--space:--spacing(8)]

API Reference

Popover

Root element of the popover.

PropTypeDefault
openboolean-
defaultOpenboolean-
onOpenChange(details: OpenChangeDetails) => void-
positioningPositioningOptions-
modalbooleantrue
closeOnInteractOutsidebooleantrue
closeOnEscapebooleantrue

PopoverTrigger

Opens the popover on click. Use asChild for custom trigger elements.

PropTypeDefault
asChildboolean-

PopoverAnchor

Element the popover is positioned relative to. Use when the reference is not the trigger.

PropTypeDefault
asChildboolean-

PopoverContent

Holds the popover panel content. Displayed in a portal.

PropTypeDefault
showCloseButtonbooleanfalse
classNamestring-
AttributeDefault
--space--spacing(4)

PopoverHeader

Header container. Accepts title and description props or children.

PropTypeDefault
titlestring-
descriptionstring-
classNamestring-

PopoverTitle

Accessible title for the popover panel.

PropTypeDefault
asChildboolean-
classNamestring-

PopoverDescription

Accessible description for the popover panel.

PropTypeDefault
asChildboolean-
classNamestring-

PopoverBody

Scrollable content area. Uses ScrollArea for overflow.

PropTypeDefault
classNamestring-

PopoverFooter

Footer area for actions or secondary content.

PropTypeDefault
classNamestring-

PopoverClose

Closes the popover on click. Use asChild for custom close elements.

PropTypeDefault
asChildboolean-

PopoverArrow

Optional arrow pointing toward the trigger element.

PropTypeDefault
classNamestring-
AttributeDefault
--arrow-backgroundvar(--popover)
--arrow-sizecalc(1.5 * var(--spacing))

For a complete list of props, see the Ark UI documentation.