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.
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.
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.
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.
Ensure dialog
Popovers have an accessible label. If the Popover has a heading: the PopoverContent
element should have an attribute aria-labelledby
whose value is the id of the heading. If the Popover does not have a heading: the PopoverContent
element needs an aria-label
attribute whose value acts as a title for the dialog. Ensure aria-label
text is localized, since some browsers will read it to the user.
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: