Popover is a container component that can overlay other components on page.
import { PopoverModule } from 'primeng/popover';Popover is accessed via its reference and visibility is controlled using toggle, show and hide methods with an event of the target.
In this sample, data is retrieved from the content inside the popover.
Place the Popover outside of the data iteration components to avoid rendering it multiple times.
| Id | Code | Name | Price | Image | Details |
|---|---|---|---|---|---|
| 1000 | f230fh0g3 | Bamboo Watch | $ 65 | ![]() | |
| 1001 | nvklal433 | Black Watch | $ 72 | ![]() | |
| 1002 | zz21cz3c1 | Blue Band | $ 79 | ![]() | |
| 1003 | 244wgerg2 | Blue T-Shirt | $ 29 | ![]() | |
| 1004 | h456wer53 | Bracelet | $ 15 | ![]() |
Content of the OverlayPanel is defined by content template.
show method takes two parameters, first one is the event and it is mandatory. By default the target component to align the overlay is the event target, if you'd like to align it to another element, provide it as the second parameter target.
Popover component uses dialog role and since any attribute is passed to the root element you may define attributes like aria-label or aria-labelledby to describe the popup contents. In addition aria-modal is added since focus is kept within the popup.
It is recommended to use a trigger component that can be accessed with keyboard such as a button, if not adding tabIndex would be necessary. Popover adds aria-expanded state attribute and aria-controls to the trigger so that the relation between the trigger and the popup is defined.
When the popup gets opened, the first focusable element receives the focus and this can be customized by adding autofocus to an element within the popup.
| Key | Function |
|---|---|
| tab | Moves focus to the next the focusable element within the popup. |
| shift + tab | Moves focus to the previous the focusable element within the popup. |
| escape | Closes the popup and moves focus to the trigger. |
| Key | Function |
|---|---|
| enter | Closes the popup and moves focus to the trigger. |
| space | Closes the popup and moves focus to the trigger. |