<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

Popover

A container that pops up from another element over other content. Triggered via click to give short, additional information in-context.
styleKeys: popoverscriptKeys: popover

Use Popover...

  • To show optional, additional information in context that might be useful for the user.
  • To give short definitions of terms or phrases, or to provide some extra context.

Don't use Popover...

  • To show critical information for a user to complete a task.
  • To capture information or display multiple actions. Use Modal Dialog instead.

Default

Popovers act in a similar way to tooltips, except that they show up on click rather than on hover. Refer to Popover vs tooltip for more details.

The preview has been updated.

Trigger

Use the PopoverLauncher subcomponent to place a clickable trigger element—usually a Button or Link as a Button. When triggered, the Popover is attached to its trigger element.

The preview has been updated.

Position

Popover will automatically position itself, trying to avoid its contents rendering off-screen, and it will typically have its arrowhead pointing to the center of the trigger element. With the position prop, you can specify its preferred orientation relative to the trigger element: Top, Bottom, Left, Right.

By default, the offset prop should be set to 8px. This is the space between the trigger element and the Popover.

The preview has been updated.

Content

Popovers can contain any content. We recommend content that is short and directive, that is not critical for users to complete a task. Refer to Guidelines for more info. Popovers have a maximum width of 375px.

The preview has been updated.

Full bleed

Use fullBleed to remove the padding around the Popover’s contents. Useful when placing an edge-to-edge image in a Popover.

The preview has been updated.

With a close button

Use the PopoverCloser component with a Button to configure its click handlers to close the Popover. We recommend styling and positioning the close button as demonstrated above.

The preview has been updated.

As a dialog

Use dialog if the Popover contents contain interactive elements.

The preview has been updated.

Control

At times, you might want to control the popover state programmatically, i.e., without the user actually clicking the popover button. This can be achieved by using React's ref to trigger the button click. Below's the sample:

Accessibility

The PopoverContent component needs an accessible name that briefly describes its purpose or function. The name will be applied to its underlying dialog element and used by assistive technologies to describe it to its users.

If visible text already exists that summarizes its purpose, the PopoverContent element should have an aria-labelledby attribute whose value is the id of the element containing that text. Examples include a heading inside the PopoverContent, the text in the PopoverLauncher, or nearby text on the page.

If no visible text exists that summarizes its purpose, the PopoverContent element should have an aria-label attribute whose value acts as the name for the dialog. Ensure the aria-label text is localized since it will be read to the user.

The preview has been updated.

Content

  • Show additional information in-context with the triggering element.
  • Keep content brief.
  • Don’t place critical information in a Popover.
    • This is considered a UX bad practice as user may miss it.
    • Search engines won’t see any information that requires interaction to view. If your use case requires it, ensure the Popover content is part of the page's source HTML on the server.

Interactive elements

  • Make the trigger element accessible and clickable via keyboard, usually a button. You will need to ensure the trigger element is keyboard-accessible (refer to Keyboard Access).
  • Don’t remove the arrowhead that points to the trigger element.

Layout

  • Set the offset—the space between the trigger element and the Popover—to 8px unless a special case requires a different value.
  • Don’t try to manually position the Popover. Use the position prop instead.
  • Don’t use the expanded prop on any Popover inside a Modal Dialog as the Popover will not display in the desired location.

Popover vs tooltip

SWAN doesn’t support tooltip components. Tooltips show contextual information on hover or keyboard focus. However, this behavior is not accessible to keyboard users, screen readers, or users on mobile. The Popover component can be used in much the same way, however, it must be triggered by a click. A Popover can also contain interactive elements.

Popover vs Modal Dialog

Popover

  • Popovers are less disruptive and more dynamic than a Modal Dialog as they give succinct additional information in-context.
  • Appears next to the trigger, pointing to the trigger to show that the popover’s contents are contextual.
  • Have a max width of 375px.
  • Closed when the user clicks on anything else on the page.
  • Modal Dialogs overlay the entire page.
  • A new “mode” for inputting or reviewing information.
  • Removes other page distractions for a more focused experience.
  • Depending on the complexity of the information and the context in which the user accesses it, consider whether a new page should be presented instead of a Modal Dialog.

Props

Popover
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
position"left" | "right" | "top" | "bottom" | nullfalse
Position in which should the popover be shown
top
PopoverContent
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
offsetnumberfalse
The offset distance from the trigger element.
null
childrenReactNodefalse
The content to be displayed within the popover.
null
fullBleedbooleanfalse
Specifies whether the popover should take up the full available width. removes the padding around the Popover's content
undefined
isNonModalbooleanfalse
Specifies whether the popover is used in a non-modal context.
false
hideArrowbooleanfalse
Whether to hide the popover arrow
false
portalContainerElementfalse
The container for the portal where the popover is rendered.
null
dialogboolean | nullfalse
⚠️ Deprecated - popovers are always treated as dialogs
Should it be wrapped inside a dialog popover or not?
false
placementPlacementfalse
The placement of the popover. eg: "bottom start", "top end", "top", "bottom"
top
labelTextstringfalse
⚠️ Deprecated - Use `aria-label` or `aria-labelledby` instead.
The accessible label to be applied to the popover dialog.
null
aria-labelstringfalse
The label text for the dialog popover. If provided, it will be used as the aria-label for the dialog element. If not provided, the popover will use the aria-labelledby attribute to reference an element containing the label text. If neither is provided, the trigger element's id will be used as the aria-labelledby reference.
null
aria-labelledbystringfalse
The id of an element containing the label text for the dialog popover. If provided, it will be used as the aria-labelledby attribute for the dialog element. If not provided, the popover will use the aria-label attribute to set the label for the dialog. If neither is provided, the trigger element's id will be used as the aria-labelledby reference.
null
PopoverLauncher
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
PopoverCloser
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
PopoverDialog
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
aria-labelstringfalse
Defines a string value that labels the current element. The label text for the dialog popover. If provided, it will be used as the aria-label for the dialog element. If not provided, the popover will use the aria-labelledby attribute to reference an element containing the label text. If neither is provided, the trigger element's id will be used as the aria-labelledby reference. @see aria-labelledby.
null
aria-labelledbystringfalse
Identifies the element (or elements) that labels the current element. The id of an element containing the label text for the dialog popover. If provided, it will be used as the aria-labelledby attribute for the dialog element. If not provided, the popover will use the aria-label attribute to set the label for the dialog. If neither is provided, the trigger element's id will be used as the aria-labelledby reference. @see aria-describedby.
null