Popover

The Popover component provides a simple way to add popovers.

Popover

The Popover component allows you to easily add popovers with the correct attributes and positioning. For it to work you will need to create a trigger on your own. It is also possible to create a popover without using the component itself. Note that elements containing a container query item wont work with the default popover width setting. Check out the object documentation for more information about the attributes.

I'm a popover

This is a card, inside a popover. I need to make sure there is a set width for my container or it wont work because of how container queries operate.

Horizontal Placement (Viewport)

These examples use horizontal placement anchored to the viewport. Set horizontalPlacement to left, center, or right.

I'm a popover

This popover is placed at the left relative to the viewport.

I'm a popover

This popover is placed at the center relative to the viewport.

I'm a popover

This popover is placed at the right relative to the viewport.

Vertical Placement (Viewport)

These examples use vertical placement anchored to the viewport. Set verticalPlacement to top, center, or bottom.

I'm a popover

This popover is placed at the top relative to the viewport.

I'm a popover

This popover is placed at the center relative to the viewport.

I'm a popover

This popover is placed at the bottom relative to the viewport.

Combination Placement (Viewport)

These examples combine horizontal and vertical viewport placement values for full 3×3 placement control.

I'm a popover

This popover is placed at top-left relative to the viewport.

I'm a popover

This popover is placed at top-center relative to the viewport.

I'm a popover

This popover is placed at top-right relative to the viewport.

I'm a popover

This popover is placed at center-left relative to the viewport.

I'm a popover

This popover is placed at center-center relative to the viewport.

I'm a popover

This popover is placed at center-right relative to the viewport.

I'm a popover

This popover is placed at bottom-left relative to the viewport.

I'm a popover

This popover is placed at bottom-center relative to the viewport.

I'm a popover

This popover is placed at bottom-right relative to the viewport.

Horizontal Placement (Relative to Trigger)

These examples use horizontal placement relative to the trigger element. Enable relativeToTrigger and set horizontalPlacement to left, center, or right.

I'm a popover

This popover is placed at the left relative to its trigger element.

I'm a popover

This popover is placed at the center relative to its trigger element.

I'm a popover

This popover is placed at the right relative to its trigger element.

Vertical Placement (Relative to Trigger)

These examples use vertical placement relative to the trigger element. Enable relativeToTrigger and set verticalPlacement to top, center, or bottom.

I'm a popover

This popover is placed at the top relative to its trigger element.

I'm a popover

This popover is placed at the center relative to its trigger element.

I'm a popover

This popover is placed at the bottom relative to its trigger element.

Combination Placement (Relative to Trigger)

These examples combine horizontal and vertical placement values relative to the trigger element.

I'm a popover

This popover is placed at top-left relative to its trigger element.

I'm a popover

This popover is placed at top-center relative to its trigger element.

I'm a popover

This popover is placed at top-right relative to its trigger element.

I'm a popover

This popover is placed at center-left relative to its trigger element.

I'm a popover

This popover is placed at center-center relative to its trigger element.

I'm a popover

This popover is placed at center-right relative to its trigger element.

I'm a popover

This popover is placed at bottom-left relative to its trigger element.

I'm a popover

This popover is placed at bottom-center relative to its trigger element.

I'm a popover

This popover is placed at bottom-right relative to its trigger element.

Backdrop

These examples demonstrate the use of the popover backdrop. The backdrop can be styled using the data-popover-backdrop attribute.

I'm a popover

This is a popover with a backdrop.

API

Parameter Default Description
null The unique identifier for the popover. Its needed for the feature to work properly.
auto The type of the popover. Valid value is 'auto'.
null The horizontal placement of the popover relative to its trigger element. Valid values are 'left', 'right' or 'center'.
null The vertical placement of the popover relative to its trigger element. Valid values are 'top', 'center' or 'bottom'.
false Determines if the popover should be positioned relative to its trigger element. Valid values are true or false.
false Determines if the popover should have a backdrop. Valid values are true or false.

CSS API

Variable Default Type Values Description
var(--color--alpha) rgba - Used for overlays. Includes opacity — set both color and alpha together.