<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. If Popover contents contain interactive elements, use the dialog prop (Refer to Popover as a dialog). 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.

As a dialog

Use dialog if the Popover contents contain interactive elements. A dialog Popover must contain a PopoverCloser element; SWAN doesn’t dictate what this element should look like. You may consider using a close icon as a button.

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:

Share

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).
  • Use the dialog prop if a Popover contains any interactive elements.
  • 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" | "bottom" | "top" | nullfalse
Position in which should the popover be shown
null
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
placementPlacementfalse
The placement of the popover. eg: "bottom start", "top end", "top", "bottom"
top
isNonModalbooleanfalse
Specifies whether the popover is used in a non-modal context.
null
hideArrowbooleanfalse
-
null
labelTextstringfalse
The label text for accessibility.
null
portalContainerElementfalse
The container for the portal where the popover is rendered.
null
dialogboolean | nullfalse
Should it be wrapped inside th the dialog popover or not?
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.
Was this page useful?

Thanks for your feedback!

Feel free to include your name if you wish to have a follow up conversation.


Published: Jan 7, 2022Last updated: Oct 17, 2024