Avara UI

Shadcn Popover

A portal-rendered floating panel (Popover, PopoverTrigger, PopoverContent) with collision flipping, viewport clamping, and click-outside/Escape dismissal.

Applies to this page's previews only

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

  • Hover/focus text hints — use Tooltip
  • Blocking modal confirmations — use Dialog

Agent notes

  • Named exports: Popover, PopoverTrigger, PopoverContent from @/components/custom/blocks/PopoverBlock
  • Set panel width via className on PopoverContent; tune gaps with sideOffset and collisionPadding
  • Open state is internal: Popover takes only children, with no open or onOpenChange prop
  • PopoverTrigger always renders its own div wrapper; the asChild prop is declared but not implemented, so nest your element inside it
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

ComponentPropTypeDefaultDescription
PopoverContentside"top" | "bottom" | "left" | "right""bottom"

The preferred side of the trigger to render the popover content.

PopoverContentalign"start" | "center" | "end""center"

The preferred alignment against the chosen side. For example, side="bottom" align="start" aligns the left edge of the popover with the left edge of the trigger.

PopoverContentsideOffsetnumber8

The distance (in pixels) to render the popover away from the trigger element.

PopoverContentavoidCollisionsbooleantrue

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 side="left" / "right" and align="start" / "end" from being cropped on phones. Set to false to pin the panel to side/ align regardless.

PopoverContentcollisionPaddingnumber8

Minimum gap (in pixels) kept between the panel and the viewport edges when avoidCollisions is on.

All ComponentsclassNamestringundefined

Standard Tailwind CSS overrides. By default, PopoverContent has a fixed width (w-72), which you can easily override here.

Works with other components

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.