Popover

<wa-popover> Stable Since 3.0

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.

Popovers display interactive content when their anchor element is clicked. Unlike tooltips, popovers can contain links, buttons, and form controls. They appear without an overlay and will close when you click outside or press Escape. Only one popover can be open at a time.

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

Take Action
Show popover

Examples

Link to This Section

Assigning an Anchor

Link to This Section

Use <wa-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 Web Awesome button.

I'm anchored to a native button.

Make sure the anchor element exists in the DOM before the popover connects. If it doesn't exist, the popover won't attach and you'll see a console warning.

Opening and Closing

Link to This Section

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

Link to This Section

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

Link to This Section

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

Link to This Section

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

Setting a Maximum Width

Link to This Section

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.

Setting Focus

Link to This Section

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

Submit
Feedback

Importing

Link to This Section

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

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/[email protected]/components/popover/popover.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/popover/popover.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/popover/popover.js';

To import this component for React 18 or below, use the following code:

import WaPopover from '@awesome.me/webawesome/dist/react/popover/index.js';

Slots

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

Methods

Link to This Section

Learn more about methods.

Events

Link to This Section

Learn more about events.

CSS custom properties

Link to This Section

Learn more about CSS custom properties.

Custom States

Link to This Section

Learn more about custom states.

CSS parts

Link to This Section

Learn more about CSS parts.

Dependencies

Link to This Section

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

Need a hand? Report a bug Ask for help
    No results