ProComponents, templates & AI tooling
HeroUI
27.7k

Popover

Displays rich content in a portal triggered by a button or any custom element

Usage

import { Popover } from '@heroui/react';

Anatomy

import { Popover } from '@heroui/react';

export default () => (
  <Popover>
    <Popover.Trigger/>
    <Popover.Content>
      <Popover.Arrow />
      <Popover.Dialog>
        <Popover.Heading/>
        {/* content goes here */}
      </Popover.Dialog>
    </Popover.Content>
  </Popover>
)

Examples

With Arrow

Interactive Content

Placement

Render Function

Customization

Tailwind CSS

Global CSS

To customize the Popover component classes, you can use the @layer components directive. Learn more.

@layer components {
  .popover {
    @apply rounded-xl shadow-2xl;
  }

  .popover__dialog {
    @apply p-4;
  }

  .popover__heading {
    @apply text-lg font-bold;
  }
}

Styling Reference

HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.

CSS Classes

The Popover component uses these CSS classes (View source styles):

Base Classes

  • .popover - Base popover container styles
  • .popover__dialog - Dialog content wrapper
  • .popover__heading - Heading text styles
  • .popover__trigger - Trigger element styles

Interactive States

The component supports animation states:

  • Entering: [data-entering] - Applied during popover appearance
  • Exiting: [data-exiting] - Applied during popover disappearance
  • Placement: [data-placement="*"] - Applied based on popover position
  • Focus: :focus-visible or [data-focus-visible="true"]

API Reference

Popover

PropTypeDefaultDescription
childrenReact.ReactNode-Trigger and content elements
isOpenboolean-Controls popover visibility (controlled)
defaultOpenbooleanfalseInitial open state (uncontrolled)
onOpenChange(isOpen: boolean) => void-Called when open state changes

Popover.Content

PropTypeDefaultDescription
childrenReact.ReactNode-Content to display in the popover
placement"top" | "bottom" | "left" | "right" (and variants)"bottom"Placement of the popover
offsetnumber8Distance from the trigger element
shouldFlipbooleantrueWhether popover can change orientation to fit
classNamestring-Additional CSS classes
renderDOMRenderFunction<keyof React.JSX.IntrinsicElements, PopoverRenderProps>-Overrides the default DOM element with a custom render function.

Popover.Dialog

PropTypeDefaultDescription
childrenReact.ReactNode-Dialog content
classNamestring-Additional CSS classes

Popover.Trigger

PropTypeDefaultDescription
childrenReact.ReactNode-Element that triggers the popover
classNamestring-Additional CSS classes

Popover.Arrow

PropTypeDefaultDescription
childrenReact.ReactNode-Custom arrow element
classNamestring-Additional CSS classes
renderDOMRenderFunction<keyof React.JSX.IntrinsicElements, OverlayArrowRenderProps>-Overrides the default DOM element with a custom render function.

On this page