ion-popover
Popovers in Ionic v5 may collide with the popover feature on newer versions of browsers which can cause Ionic's popovers to not render. We recommend upgrading to the latest version of Ionic to avoid this issue.
A Popover is a dialog that appears on top of the current page. It can be used for anything, but generally it is used for overflow actions that don't fit in the navigation bar.
Presenting
To present a popover, call the present
method on a popover instance. In order to position the popover relative to the element clicked, a click event needs to be passed into the options of the present
method. If the event is not passed, the popover will be positioned in the center of the viewport.
Customization
Popover uses scoped encapsulation, which means it will automatically scope its CSS by appending each of the styles with an additional class at runtime. Overriding scoped selectors in CSS requires a higher specificity selector.
We recommend passing a custom class to cssClass
in the create
method and using that to add custom styles to the host and inner elements. This property can also accept multiple classes separated by spaces. View the Usage section for an example of how to pass a class using cssClass
.
/* DOES NOT WORK - not specific enough */
.popover-content {
background: #222;
}
/* Works - pass "my-custom-class" in cssClass to increase specificity */
.my-custom-class .popover-content {
background: #222;
}