<cs-popover>
StableHelpersSince 0.1

Popovers display contextual content and interactive elements in a floating panel anchored to a trigger. Use them for rich tooltips, menus, or any content that appears on demand without navigating away.

This popover contains interactive content that users can engage with directly.

Take Action
Show popover

Unlike tooltips, popovers can contain links, buttons, and form controls. They appear without an overlay and close when you click outside or press Escape. Only one popover can be open at a time.

Examples

Anchor

Use <cs-button> or <button> elements as popover anchors. Connect the popover to its anchor by setting the for attribute to match the anchor’s id.

Show Popover I'm anchored to a Cornerstone button.

I'm anchored to a native button.

The anchor must exist in the DOM before the popover connects.
Otherwise the popover won’t attach and you’ll see a console warning.

Opening & Closing

Popovers show when you click their anchor element. You can also control them programmatically by setting the open property to true or false.

Use data-popover="close" on any button inside a popover to close it automatically.

The button below has data-popover="close" so clicking it will close the popover.

Dismiss
Show popover

Placement

Use the placement attribute to set where the popover appears relative to its anchor. The popover will automatically reposition if there isn’t enough space in the preferred location. The default placement is top.

Top I'm on the top Bottom I'm on the bottom Left I'm on the left Right I'm on the right

Distance

Use the distance attribute to control how far the popover appears from its anchor.

Near I'm very close Far I'm farther away

Arrow Size

Use the --arrow-size custom property to change the size of the popover’s arrow. To remove it, use the without-arrow attribute.

Big arrow I have a big arrow No arrow I don't have an arrow

Max Width

Use the --max-width custom property to control the maximum width of the popover.

Toggle me Popovers will usually grow to be much wider, but this one has a custom max width that forces text to wrap.

Initial Focus

Use the autofocus global attribute to move focus to a specific form control when the popover opens.

Submit
Feedback

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/popover/popover.js';
import './cornerstone/components/popover/popover.js';
import CsPopover from '@cruglobal/cornerstone-components/react/popover/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The popover's content. Interactive elements such as buttons and links are supported.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
distancedistanceThe distance in pixels from which to offset the popover away from its target.number8
forforThe ID of the popover's anchor element. This must be an interactive/focusable element such as a button.string | nullnull
openopenShows or hides the popover.booleanfalseYes
placementplacementThe preferred placement of the popover. Note that the actual placement may vary as needed to keep the popover inside of the viewport.'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end''top'
skiddingskiddingThe distance in pixels from which to offset the popover along its target.number0
withoutArrowwithout-arrowRemoves the arrow from the popover.booleanfalseYes

Methods

Learn more about methods.

NameDescriptionArguments
hide()Hides the popover.
show()Shows the popover.

Events

Learn more about events.

NameDescription
cs-after-hideEmitted after the popover has hidden and all animations are complete.
cs-after-showEmitted after the popover has shown and all animations are complete.
cs-hideEmitted when the popover begins to hide. Canceling this event will stop the popover from hiding.
cs-showEmitted when the popover begins to show. Canceling this event will stop the popover from showing.

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--arrow-sizeThe size of the tiny arrow that points to the popover (set to zero to remove).0.375rem
--hide-durationThe speed of the hide animation.var(--cs-transition-fast)
--max-widthThe maximum width of the popover's body content.25rem
--show-durationThe speed of the show animation.var(--cs-transition-fast)

Custom States

Learn more about custom states.

NameDescriptionCSS selector
openApplied when the popover is open.:state(open)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
bodyThe popover's body where its content is rendered.::part(body)
dialogThe native dialog element that contains the popover content.::part(dialog)
popupThe internal <cs-popup> element that positions the popover.::part(popup)
popup__arrowThe popup's exported arrow part. Use this to target the popover's arrow.::part(popup__arrow)
popup__popupThe popup's exported popup part. Use this to target the popover's popup container.::part(popup__popup)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.