Installation
Add Component
Copy the code snippet below into you components folder.
Integrate Recipe
Integrate this recipe in to your Panda config.
Usage
Shortcuts
The Popover provides a shortcuts for common use cases.
Arrow
The Popover.Arrow renders the Popover.ArrowTip component within in by
default.
This works:
This might be more concise, if you don't need to customize the arrow tip.
Examples
Controlled
Use the open and onOpenChange to control the visibility of the popover.
Lazy Mount
Use the lazyMounted and/or unmountOnExit prop to defer the mounting of the popover content until it's opened.
Placement
Use the positioning.placement prop to change the position of the popover.
Offset
Use the positioning.offset prop to adjust the position of the popover content.
Same Width
Use the positioning.sameWidth prop to make the popover content the same width
as the trigger.
Nested
To use the Popover within a Popover, you need to avoid portalling the nested Popover.Positioner to the document's body.
Form
Here's an example of a popover with a form inside.
Initial Focus
Use the initialFocusEl prop to set the initial focus of the popover content.
Custom Background
Use the --popover-bg CSS variable to change the background color of the
popover content and its arrow.
Within Dialog
To use the Popover within a Dialog, you need to avoid portalling the Popover.Positioner to the document's body.
If you have set scrollBehavior="inside" on the Dialog, you need to:
- Set the popover positioning to
fixedto avoid the popover from being clipped by the dialog. - Set
hideWhenDetachedtotrueto hide the popover when the trigger is scrolled out of view.