Skip to main content

Popover

Used to display a non-modal dialog that floats around a trigger.

Anatomy

  1. Trigger
  2. Container
  3. Content

Import

import { PopoverContent, PopoverProvider } from '@pluralsight/react'

The Popover shares the same components as the Modal family.

Usage

a11y Best Practices

Instead of using popovers and hiding important information, consider writing clear, succinct, always visible descriptions. If you have space, don't use tooltips or popovers. Just provide clear labels and sufficient body text.

Basic

To display a Popover, just wrap the trigger and popover content with a PopoverProvider and use the PopoverContent to wrap the body of the popover.

To open and close the Popover, use the show and close methods.

Result
Loading...
Live Editor

Positioning

To change the position of the Popover, add the position attribute to the Provider element. The values are top, bottom, left, and right.

Result
Loading...
Live Editor

Customizing

You can customize the Popover the same way as you would the Dialog family.

Behavior

Do: use the Popover to display a message with links.

Don't: use the Popover to display a message without actionable content. Instead use the Tooltip.

API

PopoverProvider

Props

NameTypeDescription
positionstringThe position of the Popover. Can be top, bottom, left, or right.

PopoverContent

Props

NameTypeDescription
bodyIdstringThe id of the body element.
headingIdstringThe id of the heading element.
refobjectA ref to the PopoverContent.

Accessibility

The Popover shares the same accessibility as the Dialog family.