Shadcn Popover
A portal-rendered floating panel (Popover, PopoverTrigger, PopoverContent) with collision flipping, viewport clamping, and click-outside/Escape dismissal.
About Shadcn Popover
What it is. Popover, PopoverTrigger, and PopoverContent display interactive menus, filters, or forms anchored to a trigger element.
How it is built. Portals into document.body via createPortal so overflow-hidden ancestors never clip it, flips side/align automatically when space is tight (avoidCollisions), and dismisses on outside click or Escape.
When to use it. Use Popover for click-triggered menus, settings panels, and inline pickers. For hover/focus text hints, use Tooltip; for blocking tasks, use Dialog.
For AI agents
Hand your agent this brief or the Markdown page, not a screenshot.
When to use
- Click-triggered floating panels (account menus, filter controls, quick settings)
When not to use
Agent notes
- Named exports:
Popover,PopoverTrigger,PopoverContentfrom@/components/custom/blocks/PopoverBlock - Set panel width via
classNameonPopoverContent; tune gaps withsideOffsetandcollisionPadding - Open state is internal:
Popovertakes onlychildren, with noopenoronOpenChangeprop PopoverTriggeralways renders its owndivwrapper; theasChildprop is declared but not implemented, so nest your element inside it
- Markdown
- /docs-md/nextjs-popover.md
- Install
npx shadcn@latest add https://avaraui.com/r/popover.json- Registry name
@avara-ui/popover, through the shadcn MCP server- Index
- llms.txt lists every page, or add the agent skill once
Props Reference
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
PopoverContent | side | "top" | "bottom" | "left" | "right" | "bottom" | The preferred side of the trigger to render the popover content. |
PopoverContent | align | "start" | "center" | "end" | "center" | The preferred alignment against the chosen side. For example,
|
PopoverContent | sideOffset | number | 8 | The distance (in pixels) to render the popover away from the trigger element. |
PopoverContent | avoidCollisions | boolean | true | Flips the panel to the opposite side and shifts it back into view when
the preferred placement would overflow the viewport — this is what
keeps |
PopoverContent | collisionPadding | number | 8 | Minimum gap (in pixels) kept between the panel and the viewport edges
when |
| All Components | className | string | undefined | Standard Tailwind CSS overrides. By default,
|
Works with other components
- Pair
Popoverwith Button triggers and Color Picker or Date Picker panels. - Use Context Menu for right-click menus instead of left-click popovers.
Why won't PopoverContent get clipped inside overflow-hidden containers?
PopoverContent renders into the trigger's document.body through createPortal, so ancestors with overflow-hidden cannot cut it off. It is positioned from the trigger's bounding box and kept inside the viewport with collisionPadding while avoidCollisions is on.
How do I control the Popover open state?
You cannot through props: Popover accepts only children and keeps open in internal state. It toggles on a trigger click, Enter or Space, and closes on an outside mousedown or touchstart, or on Escape. Clicks inside PopoverContent do not close it.
How do I stop PopoverContent from flipping or moving on small screens?
Pass avoidCollisions={false} to pin the panel to side and align, which also turns off viewport clamping and size capping. By default it flips to the opposite side when there is more room there, drops to above or below the trigger when neither horizontal side fits, and scrolls if still too tall.
How do I change the PopoverContent width?
Pass a width class through className, for example className="w-64". The default is w-72, limited by max-w-[calc(100vw-1rem)], and the width stays a single class so your override applies at every breakpoint. Padding is p-3, rising to lg:p-4.
Is Popover keyboard accessible?
Partly. PopoverTrigger is a div with role="button", tabIndex={0}, aria-haspopup="dialog" and aria-expanded, and opens with Enter or Space. The panel has role="dialog" and closes on Escape, but focus is not moved or trapped, so use Dialog for modal tasks.
Can PopoverTrigger use asChild with my own Button?
No. asChild appears in the PopoverTriggerProps type but the component never reads it, so the trigger always renders its own div. Nest your element inside PopoverTrigger, as the demos do. It adds no npm dependencies and has no next/* imports.