1. docs
  2. components
  3. popover

Popover

Displays a Popover.


Preview

Usage

import { Popover } from "@/ui/popover";
import { DialogTrigger } from "@/ui/dialog";
<DialogTrigger>
  <Button size="icon">
    <BellIcon />
  </Button>
  <Popover showArrow>your content</Popover>
</DialogTrigger>

API Reference

NameTypeDefaultDescription
triggerstringThe name of the component that triggered the popover. This is reflected on the element as the data-trigger attribute, and can be used to provide specific styles for the popover depending on which element triggered it.
triggerRefRefObject<Element>The ref for the element which the popover positions itself with respect to. When used within a trigger component such as DialogTrigger, MenuTrigger, Select, etc., this is set automatically. It is only required when used standalone.
isEnteringbooleanWhether the popover is currently performing an entry animation.
isExitingbooleanWhether the popover is currently performing an exit animation.
UNSTABLE_portalContainerElementdocument.bodyThe container element in which the overlay portal will be placed. This may have unknown behavior depending on where it is portalled to.
offsetnumber8The additional offset applied along the main axis between the element and its anchor element.
placementPlacementbottomThe placement of the element with respect to its anchor element.
containerPaddingnumber12The placement padding that should be applied between the element and its surrounding container.
crossOffsetnumber0The additional offset applied along the cross axis between the element and its anchor element.
shouldFlipbooleantrueWhether the element should flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.
isNonModalbooleanWhether the popover is non-modal, i.e. elements outside the popover may be interacted with by assistive technologies. Most popovers should not use this option as it may negatively impact the screen reader experience.
isKeyboardDismissDisabledbooleanfalseWhether pressing the escape key to close the popover should be disabled. Most popovers should not use this option. When set to true, an alternative way to close the popover with a keyboard must be provided.
shouldCloseOnInteractOutside(element: Element) => booleanWhen user interacts with the argument element outside of the popover ref, return true if onClose should be called. This gives you a chance to filter out interaction with elements that should not dismiss the popover.
boundaryElementElementdocument.bodyElement that serves as the positioning boundary.
scrollRefRefObject<Element>overlayRefA ref for the scrollable region within the overlay.
shouldUpdatePositionbooleantrueWhether the overlay should update its position automatically.
arrowBoundaryOffsetnumber0The minimum distance the arrow's edge should be from the edge of the overlay element.
isOpenbooleanWhether the overlay is open by default (controlled).
defaultOpenbooleanWhether the overlay is open by default (uncontrolled).
childrenReactNode | functionThe children of the component. A function may be provided to alter the children based on component state.
classNamestring | functionThe CSS className for the element. A function may be provided to compute the class based on component state.
styleCSSProperties | functionThe inline style for the element. A function may be provided to compute the style based on component state.

Events

NameTypeDescription
onOpenChange(isOpen: boolean) => voidHandler that is called when the overlay's open state changes.