PeakUI

Popover

Overlay anchored to a trigger

Usage

import {Popover} from "@peakui/react";

Anatomy

import {Button, Popover} from "@peakui/react";

export default () => (
  <Popover>
    <Button>Open popover</Button>
    <Popover.Content>
      <Popover.Dialog>
        <Popover.Arrow />
        <Popover.Heading>Popover heading</Popover.Heading>
        <p>Popover content</p>
      </Popover.Dialog>
    </Popover.Content>
  </Popover>
);

Examples

With Arrow

Placement

Custom Triggers

Customization

Tailwind CSS

Global CSS

@layer components {
  .popover {
    @apply rounded-lg border border-border/80 shadow-lg;
  }

  .popover__heading {
    @apply text-xs uppercase tracking-wide;
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

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

Base Classes

  • .popover - Base popover styles with animations
  • .popover__dialog - Dialog element styles
  • .popover__heading - Heading element styles
  • .popover__trigger - Trigger element styles

Slots

  • [data-slot="popover"] - The popover content element
  • [data-slot="popover-trigger"] - The Popover.Trigger element
  • [data-slot="popover-dialog"] - The Popover.Dialog element
  • [data-slot="popover-heading"] - The Popover.Heading element
  • [data-slot="popover-overlay-arrow"] - The default arrow SVG
  • [data-slot="popover-overlay-arrow-group"] - The arrow wrapper

Interactive States

The popover content carries RAC animation and positioning states:

  • Entering: [data-entering="true"]
  • Exiting: [data-exiting="true"]
  • Placement: [data-placement="top | bottom | left | right"]

The trigger supports both pseudo-classes and data attributes:

  • Focus: :focus-visible or [data-focus-visible="true"]
  • Disabled: :disabled or [aria-disabled="true"]

API Reference

Popover

PropTypeDefaultDescription
childrenReact.ReactNode-The trigger element followed by Popover.Content
isOpenboolean-Controlled open state
defaultOpenbooleanfalseInitially open, without controlling
onOpenChange(isOpen: boolean) => void-Called when the popover opens or closes
...restDialogTriggerProps-React Aria DialogTrigger attributes

Popover.Content

PropTypeDefaultDescription
childrenReact.ReactNode-Content of the popover
placementPlacement'bottom'Placement relative to the trigger: 'top', 'bottom', 'left', 'right' with start/end/top/bottom variants
offsetnumber8Distance from the trigger element
crossOffsetnumber0Cross-axis offset from the trigger
shouldFlipbooleantrueWhether the popover flips when it does not fit
containerPaddingnumber12Distance the popover keeps from the viewport edge
arrowBoundaryOffsetnumber0Boundary offset for the arrow positioning
classNamestring | ((renderProps) => string)-Additional classes, or a function of the popover state
renderDOMRenderFunction<'div', PopoverRenderProps>-Replaces the rendered <div> with your own element
...restPopoverProps-React Aria Popover attributes

Popover.Dialog

PropTypeDefaultDescription
childrenReact.ReactNode | (({close}) => React.ReactNode)-Dialog content; a function receives a close callback
aria-labelstring-Accessible name when no Popover.Heading is present
classNamestring-Additional classes
...restDialogProps-React Aria Dialog attributes

Popover.Trigger

PropTypeDefaultDescription
childrenReact.ReactNode-Non-interactive element to make pressable
classNamestring-Additional classes
renderDOMRenderFunction<E, undefined>-Replaces the rendered <div> with your own element; E defaults to 'div'
...restHTMLAttributes-The attributes of the rendered element

Popover.Arrow

PropTypeDefaultDescription
childrenReact.ReactNode-Custom arrow element; defaults to a 12x12 SVG
classNamestring-Additional classes
...restOverlayArrowProps-React Aria OverlayArrow attributes

Popover.Heading

PropTypeDefaultDescription
childrenReact.ReactNode-Heading text; labels the dialog via aria-labelledby
classNamestring-Additional classes
...restHeadingProps-React Aria Heading attributes

Render Props

PropTypeDescription
Popover.Content className(renderProps: PopoverRenderProps) => stringComputes classes from placement, isEntering, isExiting, trigger and state
Popover.Dialog children(opts: {close: () => void}) => React.ReactNodeRenders content with a callback that closes the popover

On this page