structyl

Popover API

View component

The full prop reference for the Popover component. Displays rich content in a portal, triggered by a button.

Import

tsx
import { Popover } from '@structyl/styled';

Props

Root

Wrapper component that manages popover state and context

PropTypeDefault
children#React.ReactNode

Child components (Trigger, Portal, Content, etc.)

—
open#boolean

Controlled open state

—
defaultOpen#boolean

Initial open state when uncontrolled

false
onOpenChange#(open: boolean) => void

Callback fired when open state changes

—
modal#boolean

Whether popover should act as a modal (traps focus, disables outside interactions)

false

Trigger

Button that toggles the popover open/closed

PropTypeDefault
asChild#boolean

Render as child element instead of button

—
className#string

CSS class name

—
*#React.ComponentPropsWithoutRef<'button'>

All standard HTML button attributes (onClick, disabled, aria-*, etc.)

—

Anchor

Optional custom anchor point for positioning; without this, Trigger serves as the anchor

PropTypeDefault
asChild#boolean

Render as child element instead of div

—
className#string

CSS class name

—
*#React.ComponentPropsWithoutRef<'div'>

All standard HTML div attributes

—

Portal

Container that portals the content to a DOM node (usually document.body)

PropTypeDefault
children#React.ReactNode

Child content to portal

—
container#Element | DocumentFragment | null

DOM node to portal into; defaults to document.body

—
forceMount#boolean

Force mount content even when closed

—

Content

The popover panel with positioning, animations, and interaction handling; styled variant with defaults

PropTypeDefault
className#string

CSS class name (merged with defaults)

—
container#Element | DocumentFragment | null

Portal container (styled wrapper convenience prop)

—
align#'start' | 'center' | 'end'

Alignment relative to anchor

'center'
sideOffset#number

Distance in pixels from anchor

6
side#'top' | 'right' | 'bottom' | 'left'

Preferred side to display content

—
alignOffset#number

Offset along the alignment axis

—
arrowPadding#number

Padding between arrow and content edges

—
avoidCollisions#boolean

Auto-flip or adjust position to avoid collisions

—
collisionBoundary#Element | Element[] | null

Elements to check for collision against

—
collisionPadding#number

Padding around collision boundary

—
strategy#'fixed' | 'absolute'

CSS positioning strategy

—
sticky#'partial' | 'always'

Sticky behavior when scrolling parent

—
hideWhenDetached#boolean

Hide content when anchor is not in viewport

—
updatePositionStrategy#'always' | 'optimized'

How often to update position on scroll/resize

—
forceMount#boolean

Force mount content even when closed

—
onOpenAutoFocus#(event: Event) => void

Callback before auto-focus when opening

—
onCloseAutoFocus#(event: Event) => void

Callback before auto-focus when closing

—
onEscapeKeyDown#(event: KeyboardEvent) => void

Callback when Escape key is pressed

—
onPointerDownOutside#(event: PointerDownOutsideEvent) => void

Callback when pointer down event outside content

—
onFocusOutside#(event: FocusOutsideEvent) => void

Callback when focus moves outside content

—
onInteractOutside#(event: PointerDownOutsideEvent | FocusOutsideEvent) => void

Callback for any interaction outside content

—
asChild#boolean

Render as child element instead of div

—
*#React.ComponentPropsWithoutRef<'div'>

All standard HTML div attributes (id, role, data-*, etc.)

—

Close

Button that closes the popover

PropTypeDefault
asChild#boolean

Render as child element instead of button

—
className#string

CSS class name

—
*#React.ComponentPropsWithoutRef<'button'>

All standard HTML button attributes (onClick, disabled, aria-*, etc.)

—

Arrow

Visual arrow pointing from content to anchor

PropTypeDefault
width#number

Arrow width in pixels

—
height#number

Arrow height in pixels

—
className#string

CSS class name

—
*#React.ComponentPropsWithoutRef<'svg'>

All standard SVG attributes

—

Keyboard interactions

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

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library