Popover
stableDisplays 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
pnpm dlx structyl add popoverAPI Reference
Popover.Root
Contains all popover parts.
| Prop | Type | Default |
|---|---|---|
| open | booleanControlled open state. | — |
| defaultOpen | booleanInitial open state. | — |
| onOpenChange | (open: boolean) => voidCalled when open state changes. | — |
| modal | booleanWhether outside interaction is disabled. | false |
Popover.Trigger
The button that toggles the popover.
| Prop | Type | Default |
|---|---|---|
| asChild | booleanMerge props onto the immediate child instead of rendering a default element. | false |
Popover.Anchor
Optional custom positioning anchor.
| Prop | Type | Default |
|---|---|---|
| asChild | booleanMerge props onto the immediate child instead of rendering a default element. | false |
Popover.Content
The floating content.
| Prop | Type | Default |
|---|---|---|
| side | 'top' | 'right' | 'bottom' | 'left'Preferred side of the anchor. | 'bottom' |
| sideOffset | numberDistance in px from the anchor. | 0 |
| align | 'start' | 'center' | 'end'Alignment against the anchor. | 'center' |
| onEscapeKeyDown | (event) => voidCalled when Escape is pressed. | — |
| onPointerDownOutside | (event) => voidCalled on outside pointer-down. | — |
| forceMount | booleanForce mounting for animation control. | — |
Popover.Close
A button that closes the popover.
| Prop | Type | Default |
|---|---|---|
| asChild | booleanMerge props onto the immediate child instead of rendering a default element. | false |
Popover.Arrow
An optional pointing arrow.
| Prop | Type | Default |
|---|---|---|
| width | numberArrow width. | 10 |
| height | numberArrow height. | 5 |
Keyboard interactions
| Key | Description |
|---|---|
| Space / Enter | Opens / closes the popover. |
| Tab | Moves focus to the next focusable element. |
| Esc | Closes the popover and returns focus to the trigger. |