Skip to content

Popover

A Popover is a non-disruptive container that is overlaid on a web page or app, positioned near its trigger, in order to present necessary information and tasks.

Overview

When to use Popover

The Popover component is intended to be used with other components such as a ToggleButton or Link. The Popover is displayed when the user interacts with the corresponding trigger element.

  • Use a ToggleButton as a trigger to emphasize what opened the Popover, setting the ToggleButton into its toggled state when triggering the Popover.

  • Use a Link as a trigger when the Popover is meant to serve as a preview for what pressing the link will present.

Popovers facilitate communication between the system and user. They perform best when used for additional information or as a workflow within a bigger task, as they don’t require loading a new page and keep actions in context.

Popovers differ from Dialogs as they are not as disruptive, since the context of the page around the Popover remains, as there is no visual overlay on the page. That being said, they should be used sparingly and only when necessary, since they inherently hide content and require an additional action to reveal it.

Use the Popover component when:

  • Additional information needs to be displayed and separated from the page content.
  • It is helpful to have the context of the page still within view.

Avoid using Popover when:

  • The information can be displayed within the main interface.
  • The content is long or complex, like a form with numerous fields.
  • Typed input is required from the user.
  • Components that take up a large amount of space need to be used in the content.
  • The information being shown is a very brief message or explanation for an element on the page. Instead, use Tooltip.

About Popover

Popover includes the following elements.

The Popover header can contain a decorative icon, title, or standard text. A quiet, icon-only Button may be used to close the Popover.

Body

Interactive types of content or components can be included within the Popover’s body—typically Fields or other form element types of components.

  • Avoid using Cards, other elevated components, or components requiring a lot of space within the Popover.

Action buttons should appear at the start of the Popover. A primary Button (either progressive or destructive) is used to indicate the main action. A normal neutral Button can be used to indicate a default action (e.g. “Cancel”). Additionally, icon-only Buttons can be used as needed.

  • Stack action buttons based on text length when needed, placing the primary button on top.

  • Don't stack action buttons when they can be placed side by side.

Arrow

Popovers have an arrow which points to the trigger.

Examples

Basic usage

This example includes text, a custom placement, and the ability to manually dismiss the Popover.

  • Use the header to align standard text content to the dismiss action.

Developer notes

Create a template ref for the trigger element, and then pass that ref to the anchor prop. The anchor prop is required to correctly position the Popover.

Ensure the toggle button's on/off state and the popover's visibility is synchronized via v-model.

Usage in TypeScript

Vue 3.5 introduced the useTemplateRef() composable to simplify the creation of template refs in Vue components using the Composition API. If you are using TypeScript, consider annotating the types for any template refs like this:

ts
// Basic component typing with ComponentPublicInstance.
const anchorRef = useTemplateRef<ComponentPublicInstance>("my-anchor-id");

More information on typing component template refs can be found in the Vue.js docs.

Article preview

This example uses the hover trigger since a link leads to a new page or section.

  • Use images and other media as needed to convey visual information in the Popover.

  • Use hover as a trigger only for elements which have a separate press action, such as a link.

Did you know?

Developer notes

The example has multiple anchor tags that displays Popover content when hovered or focused. The trigger element and Popover content is dynamically updated based on where the event took place.

  • Assign each trigger element e.g. anchor tag a template ref, and store them in the triggerElements array.
  • To show and hide the Popover on hover and focus, add mouseover, focus, mouseleave, and blur event listeners to the anchor tags that trigger a Popover.

Technical implementation

Vue usage

Props

Prop nameDescriptionTypeDefault
anchorThe triggering element that opens and closes the popover. This should be a template ref, which can be either an HTML element or a Vue component.

This must be provided so the popover can be positioned relative to the triggering element.
HTMLElement|ComponentPublicInstance|nullnull
openWhether the popover is visible. Should be provided via a v-model:open binding in the parent scope.booleanfalse
titleTitle text at the top of the popover.string''
iconIcon displayed at the start of the popover.Icon''
useCloseButtonAdd an icon-only close button to the popover header.booleanfalse
closeButtonLabelVisually-hidden label text for the icon-only close button in the header.

Omit this prop to use the default value, "Close".
string'Close'
primaryActionPrimary user action. This will display a primary button with the specified action (progressive or destructive).PrimaryModalActionnull
defaultActionDefault user action. This will display a normal button.ModalActionnull
stackedActionsWhether action buttons should be vertically stacked and 100% width.booleanfalse
renderInPlaceWhether to disable the use of teleport and render the Popover in its original location in the document.booleanfalse
placementPositioning options for the Popover.Placement'bottom'

Events

Event namePropertiesDescription
primaryWhen the primary action button is clicked.
defaultWhen the default action button is clicked.
update:opennewValue boolean - The new open/close state (true for open, false for closed)When the open/close state changes, e.g. when the close button is clicked.

Slots

NameDescriptionBindings
headerCustomizable Popover header.
defaultPopover body content.
footerCustomizable Popover footer.

Keyboard navigation

KeyFunction
TabIt moves focus to the next interactive element and, if that element is outside the Popover, it closes the Popover.
Shift + TabIt moves focus to the previous interactive element and, if that element is outside the Popover, it closes the Popover.
EscIt closes the Popover.