Popover

React Popover components display floating content anchored to a trigger element. They are commonly used for contextual information, settings panels, and inline actions that don’t require full navigation.

This Popover component is built with React and styled using Tailwind CSS. It uses React Aria Components for positioning and provides accessible focus and keyboard handling.

Installation

Install the component using the Tailgrids CLI.

npx @tailgrids/cli add popover

Anatomy

Import the component parts and combine them according to your requirements.

import { Button } from "@/components/tailgrids/core/button";
import { OverlayWrapper } from "@/components/tailgrids/core/overlay";
import { Popover, PopoverArrow } from "@/components/tailgrids/core/popover";

export default function PopoverAnatomy() {
  return (
    <OverlayWrapper>
      <Button />
      <Popover>
        // Content goes here
        <PopoverArrow />
      </Popover>
    </OverlayWrapper>
  );
}

Examples

Default

Wrap the Popover component within the OverlayWrapper and use Button as the trigger for an uncontrolled popover.

Custom Anchor

Pass a custom trigger element using the triggerRef prop.

Custom Placement

Change the popover position using the placement prop.

Placement: "bottom"

With Action

Popover content with action buttons.

API Reference

Popover

PropTypeDefaultDescription
placementPlacement"bottom"The placement of the popover relative to its anchor element.
offsetnumber8Additional offset along the main axis between the popover and anchor.
crossOffsetnumber0Additional offset along the cross axis between the popover and anchor.
containerPaddingnumber12Padding between the popover and its surrounding container.
arrowBoundaryOffsetnumber0Minimum distance the arrow's edge from the edge of the overlay.
maxHeightnumberMaximum height of the popover. Defaults to available viewport height.
shouldFlipbooleantrueWhether to flip orientation when there is insufficient room.
shouldUpdatePositionbooleantrueWhether to update position automatically.
isKeyboardDismissDisabledbooleanfalseWhether pressing Escape to close is disabled.
isNonModalbooleanWhether elements outside the popover may be interacted with by assistive tech.
shouldCloseOnInteractOutside(element: Element) => booleanFilter interactions outside the popover that should not dismiss it.
isOpenbooleanWhether the overlay is open (controlled).
defaultOpenbooleanWhether the overlay is open by default (uncontrolled).
onOpenChange(isOpen: boolean) => voidHandler called when the overlay's open state changes.
isEnteringbooleanWhether the popover is performing an entry animation.
isExitingbooleanWhether the popover is performing an exit animation.
triggerRefRefObject<Element | null>Ref for the element the popover positions relative to.
scrollRefRefObject<Element | null>Ref for the scrollable region within the overlay.
arrowRefRefObject<Element | null>Ref for the popover arrow element.
boundaryElementElementdocument.bodyElement that serves as the positioning boundary.
triggerstringName of the component that triggered the popover (reflected as data-trigger attribute).
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description.
slotstring | nullSlot name to receive props from a parent component.
idstringThe element's unique identifier.
classNamestring | ((props: PopoverRenderProps) => string)Custom class for the popover element.
styleCSSProperties | ((props) => CSSProperties)Inline style for the element.
renderDOMRenderFunctionOverride the default DOM element with a custom render function.
childrenReactNode | ((props) => ReactNode)The children of the component.

PopoverArrow

PropTypeDefaultDescription
classNamestring | ((props: OverlayArrowRenderProps) => string)"react-aria-OverlayArrow"Custom class for the arrow element.
styleCSSProperties | ((props) => CSSProperties)Inline style for the element.
childrenReactNode | ((props) => ReactNode)The children of the component. Override the default SVG triangle to render a custom arrow.
idstringThe element's unique identifier.
slotstringSlot name to receive props from a parent component.
renderDOMRenderFunctionOverride the default DOM element with a custom render function.
dirstringThe text direction (e.g. "ltr" or "rtl") for the element.
hiddenbooleanWhether the element is hidden from the accessibility tree.
inertbooleanWhether the element is inert (non-interactive and hidden from assistive tech).
langstringThe BCP47 language tag for the element.
translate"yes" | "no"Whether the page content should be translated by the browser.
roleReact.AriaRoleThe ARIA role for the element.
tabIndexnumberThe tab index of the element.
titlestringThe title attribute, providing advisory information for the element.
onClickReact.MouseEventHandler<HTMLDivElement>Handler called when the element is clicked.
onMouseEnterReact.MouseEventHandler<HTMLDivElement>Handler called when the pointer enters the element.
onMouseLeaveReact.MouseEventHandler<HTMLDivElement>Handler called when the pointer leaves the element.
onFocusReact.FocusEventHandler<HTMLDivElement>Handler called when the element receives focus.
onBlurReact.FocusEventHandler<HTMLDivElement>Handler called when the element loses focus.

Accessibility

  • Uses aria-labelledby and aria-describedby
  • Keyboard accessible with Tab, Arrow, Shift+Tab, and Escape
  • Focus is managed automatically when the popover opens and closes
  • Triggers expose data-state="open" | "closed"
  • Works with screen readers and assistive technologies
  • Supports modal focus trapping when enabled

On this page

Tailgrids Pro

Access 600+ blocks, components and templates - built for speed, consistency, and scale.

Get Tailgrids Pro