Skip to content

Popover

Floating content that appears on demand, positioned relative to a trigger element.

Features

  • ✅ Smart positioning with auto-flip and shift
  • ✅ Optional arrow pointing to trigger
  • ✅ Click to open/close or programmatic control
  • ✅ Close on outside click or escape key
  • ✅ Accessible ARIA attributes
  • ✅ Optional focus trap for modal mode
  • ✅ Multiple placement options

Basic Usage

Popover Title

This is a basic popover with some contextual information.

With Arrow

Add an arrow that points to the trigger element. The component automatically rotates the arrow tip based on the popover's placement.

Arrow Styling

The arrow tip is automatically rotated based on placement. Simply apply border-t and border-l to create the arrow shape - the rotation is handled for you.

Help & Information

Notice the arrow pointing to the trigger button. This helps establish a visual connection.

Placement Options

Positioned above

Positioned below

Positioned left

Positioned right

Programmatic Control

Control popovers programmatically using custom events with the name prop.

Programmatic Popover

This popover was opened using a custom event.

With Transitions

Smooth Animation

Alpine's transition directives make it easy to add smooth enter/leave animations.

API Reference

Root Props

PropertyTypeDefaultDescription
namestring-Unique identifier for programmatic control
openbooleanfalseInitial open state
modalbooleanfalseEnable modal mode with focus trap
closeOnInteractOutsidebooleantrueClose when clicking outside
closeOnEscapebooleantrueClose when pressing Escape
trapFocusbooleanfalseEnable focus trapping (modal mode)
placementPlacement'bottom'Position relative to trigger
offsetnumber8Distance from trigger in pixels

Placement Values

  • top, top-start, top-end
  • bottom, bottom-start, bottom-end
  • left, left-start, left-end
  • right, right-start, right-end

Parts

PartDescription
x-popover:triggerButton that toggles the popover
x-popover:positionerPositioning wrapper (managed by Floating UI)
x-popover:contentMain popover content container
x-popover:arrowOptional arrow container element
x-popover:arrow-tipOptional arrow tip (child of arrow)
x-popover:titleOptional heading element
x-popover:descriptionOptional description text
x-popover:close-triggerButton to close the popover

Data Attributes

AttributeValuesDescription
data-stateopen | closedCurrent popover state
data-scopepopoverIdentifies component scope
data-partPart nameIdentifies component part

Keyboard Interactions

KeyDescription
Space / EnterToggle popover when trigger is focused
EscapeClose popover and return focus to trigger
TabMove focus to next focusable element
Shift + TabMove focus to previous focusable element

Accessibility

  • Follows WAI-ARIA dialog pattern
  • Proper role="dialog" on content
  • Trigger has aria-haspopup and aria-expanded attributes
  • Content linked to title and description via aria-labelledby and aria-describedby
  • Focus returns to trigger on close
  • Optional focus trap for modal mode

Built with Alpine.js and inspired by Zag.js