structyl

Popover

stable

Displays rich content in a portal, triggered by a button.

Basic usage

Examples

With form fields

Use a Popover to surface an inline settings panel near its trigger.

Inline settings panel

Popover works well for compact settings that should stay near the trigger.

Features

  • Can be controlled or uncontrolled.
  • Customize side, alignment, offsets, collision handling.
  • Optional rendering of a positioned arrow.
  • Focus is fully managed and customizable.
  • Dismissing and layering behaviour is highly customizable.

Installation

bash
pnpm dlx structyl add popover

API Reference

Popover.Root

Contains all popover parts.

PropTypeDefault
openboolean

Controlled open state.

defaultOpenboolean

Initial open state.

onOpenChange(open: boolean) => void

Called when open state changes.

modalboolean

Whether outside interaction is disabled.

false

Popover.Trigger

The button that toggles the popover.

PropTypeDefault
asChildboolean

Merge props onto the immediate child instead of rendering a default element.

false

Popover.Anchor

Optional custom positioning anchor.

PropTypeDefault
asChildboolean

Merge props onto the immediate child instead of rendering a default element.

false

Popover.Content

The floating content.

PropTypeDefault
side'top' | 'right' | 'bottom' | 'left'

Preferred side of the anchor.

'bottom'
sideOffsetnumber

Distance in px from the anchor.

0
align'start' | 'center' | 'end'

Alignment against the anchor.

'center'
onEscapeKeyDown(event) => void

Called when Escape is pressed.

onPointerDownOutside(event) => void

Called on outside pointer-down.

forceMountboolean

Force mounting for animation control.

Popover.Close

A button that closes the popover.

PropTypeDefault
asChildboolean

Merge props onto the immediate child instead of rendering a default element.

false

Popover.Arrow

An optional pointing arrow.

PropTypeDefault
widthnumber

Arrow width.

10
heightnumber

Arrow height.

5

Keyboard interactions

KeyDescription
Space / EnterOpens / closes the popover.
TabMoves focus to the next focusable element.
EscCloses the popover and returns focus to the trigger.
Popover | structyl