Popover
A headless Popover component for ReactLynx. It provides primitives for positioning and anchor tracking.You can check the source code to understand how it works, and you're welcome to submit PRs to enhance its capabilities.
Basic Usage
Examples
Motion Transitions
Animate popover content with spring-based entry and tween-based exit transitions.
Extra Anchor
If you want to add an extra anchor, you can use the PopoverAnchor Component.
Cross axis offset adjustment
Use 'crossAxisOffset' on PopoverPositioner to set the skidding offset of the floating element.
Structure
Component API
PopoverRoot
The root component of the Popover, containing all of its child components.
PopoverTrigger
The element that triggers the Popover to show.
State-based styling & rendering
This component exposes runtime states through one or both of the following channels. The table lists only the channels available for each state:
- UI variant class — when supported, a class like
ui-<state>is toggled on the corresponding component node for selectors such as.ui-<state> { ... }. - Render-prop field — when supported and
childrenis a function, the state is passed in viachildren({ <state>: boolean, ... })for runtime-driven rendering.
UI variants applied by PopoverTrigger.
| Class Name | Description |
|---|---|
| ui-active | Applied while the composed trigger button is pressed and not disabled. |
| ui-animating | Applied when `status.animating` is true. |
| ui-busy | Applied while the popover is entering or leaving. |
| ui-closed | Applied when `status.closed` is true. |
| ui-disabled | Applied when the trigger is disabled. |
| ui-entering | Applied when `status.entering` is true. |
| ui-leaving | Applied when `status.leaving` is true. |
| ui-open | Applied when `status.open` is true. |
PopoverAnchor
If this component is used, the Popover will use it rather than PopoverTrigger as the real anchor.
UI variants applied by PopoverAnchor.
| Class Name | Description |
|---|---|
| ui-animating | Applied when `status.animating` is true. |
| ui-closed | Applied when `status.closed` is true. |
| ui-entering | Applied when `status.entering` is true. |
| ui-leaving | Applied when `status.leaving` is true. |
| ui-open | Applied when `status.open` is true. |
PopoverPositioner
Helps position the Content and Arrow correctly.
UI variants applied by PopoverPositioner based on its render state.
| Class Name | Render Prop | Type | Description |
|---|---|---|---|
| ui-animating | animating | boolean | The popper is doing the animations. Takes effect when transition:true. Applied when `status.animating` is true. |
| ui-closed | closed | boolean | The popper is closed. If it's force mounted, the initial status will be closed. Applied when `status.closed` is true. |
| ui-entering | entering | boolean | The popper is performing the entering animation. Takes effect when transition:true. Applied when `status.entering` is true. |
| ui-leaving | leaving | boolean | The popper is performing the leaving animation. Takes effect when transition:true. Applied when `status.leaving` is true. |
| ui-open | open | boolean | The popper is opened. Applied when `status.open` is true. |
PopoverBackdrop
A transparent backdrop that can be used to close the Popover when clicked.
UI variants applied by PopoverBackdrop.
| Class Name | Description |
|---|---|
| ui-active | Applied while the composed backdrop button is pressed and not disabled. |
| ui-animating | Applied when `status.animating` is true. |
| ui-closed | Applied when `status.closed` is true. |
| ui-disabled | Applied while the popover is entering or leaving without motion content. |
| ui-entering | Applied when `status.entering` is true. |
| ui-leaving | Applied when `status.leaving` is true. |
| ui-open | Applied when `status.open` is true. |
PopoverContent
The content of the Popover.
UI variants applied by PopoverContent.
| Class Name | Description |
|---|---|
| ui-animating | Applied when `status.animating` is true. |
| ui-closed | Applied when `status.closed` is true. |
| ui-entering | Applied when `status.entering` is true. |
| ui-leaving | Applied when `status.leaving` is true. |
| ui-open | Applied when `status.open` is true. |
PopoverMotionContent
Motion-driven content. It owns opacity when an opacity target is specified, and transform when a transform target is specified. It stays mounted until all exit properties complete. Use one motion content per popover root.
UI variants applied by PopoverMotionContent.
| Class Name | Description |
|---|---|
| ui-animating | Applied when `status.animating` is true. |
| ui-closed | Applied when `status.closed` is true. |
| ui-entering | Applied when `status.entering` is true. |
| ui-leaving | Applied when `status.leaving` is true. |
| ui-open | Applied when `status.open` is true. |
PopoverArrow
The arrow of the Popover.
size; color only affects the default triangle. Keep PopoverArrow a direct child of PopoverContent so coordinates use the bubble as their origin.{ width, height } describes the original artwork: width is the base and height is the protrusion for every placement. Left/right placements rotate the box automatically. Without children, object sizes retain the default triangle’s legacy behavior using the larger dimension.UI variants applied by PopoverArrow.
| Class Name | Description |
|---|---|
| ui-animating | Applied when `status.animating` is true. |
| ui-closed | Applied when `status.closed` is true. |
| ui-entering | Applied when `status.entering` is true. |
| ui-leaving | Applied when `status.leaving` is true. |
| ui-open | Applied when `status.open` is true. |
Supporting Types
PopoverOverlayProps
The view container of the Popover. Can be overlay or view. Controls the z-index of the popover.
PopoverMotionOptions
Motion targets and their shared default transition.
PopoverMotionValues
Numeric visual properties supported by PopoverMotionContent.
PopoverMotionTarget
A visual target and its transition settings.
PopoverMotionTransition
easeOut when its duration or easing is omitted.