Use the Popover component to display additional content or information in a small overlay that appears near the target element when triggered by a click. Popovers are useful for providing context-sensitive details without navigating away from the current page. They can be used for detailed information, tooltips with actions, interactive content, contextual help, or for notifications and alerts.
Preview
To initialize the popover, call the popover function with a trigger and popover property, where:
trigger: References the trigger element through a query selector.
trigger: References the Popover component through a query selector.
By default, the popover will appear under the trigger element with a 10pxmargin-top. To change the amount of margin, you can pass an offset property to the popover function:
0 offset
20px offset
Closing Functionality
Opened popovers can be closed by either clicking again on the trigger element, or clicking outside of the popover. This behavior can be configured using the closeOnBlur property, and the closePopover function:
You can also destroy popovers if you want to disable them or remove the related event listeners when a component unmounts. To achieve this, assign the popover function call to a variable, and call the remove method on the variable. This will render the popover non-interactive.
Close the popover using the closePopover function.
Remove the popover instance using the remove method.
Optionally disable the trigger button to indicate that the popover has been removed.
Positions
The Popover component also supports the following 12 different positions:
To change the position of the popover, specify the position property:
API
Prop
Purpose
id
Pass an ID for the popover.
className
Pass additional CSS classes for the popover.
Param
Purpose
trigger
Pass a query selector for the trigger element.
popover
Pass a query selector for the popover that should be triggered.
offset
Sets the margin of the popover from the trigger element. Defaults to 10.
closeOnBlur
Sets whether the popover should closed when the user clicks outside of it. Defaults to true.
position
Sets the position of the popover relative to the trigger element. Defaults to bottom.