Dark Light
System
Default LBBW Jira Confluence Source Code
Share
Playground

Popover

<afp-popover> Since 1.0.0 stable This component uses the light DOM, so its markup and styles are part of the regular document flow.

A popover that anchors to another element and can be triggered by click, hover, focus, or programmatic manuals.

When you click on a trigger element, a popover appears showing interactive content. Unlike simple tooltips, these can include things like links, buttons, or form fields. They show up without any background overlay and disappear if you click elsewhere or hit the Escape key. Only one popover remains visible at a time.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Show popover

Examples #

Opening #

A popover appears when its trigger element is clicked. You can also manage its visibility through code by toggling the open property between true and false.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Show popover

Closing #

To make a button inside a popover close it automatically, add the attribute data-popover="close".

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad blanditiis error facilis ipsam iure, maiores modi omnis perspiciatis quae similique sint ullam voluptatibus, voluptatum? Close popover manual
Show popover

Placement #

You can specify where the popover appears relative to its trigger element using the placement property

Note that the actual placement may vary as needed to keep the panel inside of the viewport. If set to an empty array ([]), it enables auto placement. If containing more than two items, it is automatically restricted to the provided placements. You can also input a space-separated string.

Available placements #

The following placement options are supported and can be combined to control both direction and alignment:

Primary Direction Variants
top top-start, top-end
right right-start, right-end
bottom bottom-start, bottom-end
left left-start, left-end

Examples #

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

Offset #

Use the offset.mainAxis, offset.crossAxis and offset.alignmentAxis to control how far the popover appears from its anchor.

mainAxis offset changed to 20
mainAxis
crossAxis offset changed to 40
crossAxis
alignmentAxis offset changed to 20
alignmentAxis

Strategy #

By default, the popover uses the absolute positioning strategy. You can change it to fixed if needed.

I'm using absolute positioning strategy
Absolute
I'm using fixed positioning strategy
Fixed

Duration #

You can adjust the duration for which the popover is visible/invisible (in milliseconds) using the duration property.

I will hide and show after 1 second
Show popover

Trigger #

You can control how the popover is activated using the trigger property. Possible options include click, hover, focus, and manual. Multiple options can be passed by separating them with a space. When manual is used, the popover must be activated programmatically.

I'm triggered by click
Click
I'm triggered by hover
Hover
I'm triggered by focus
Focus

Hover delay #

When using the hover trigger, you can set a delay (in milliseconds) before the popover appears or disappears using the hoverDelay (hover-delay) property.

I will show after 500ms of hovering and hide after 500ms of unhovering
Hover me

Manual control #

When using the manual trigger, you can programmatically show or hide the popover using its show(), hide() and toggle() methods.

I'm controlled manually
Content
Toggle

Auto focus #

When a popover is displayed, it automatically focuses on the first focusable element within its content. You can also set the autofocus HTML property.

Properties

Learn more about properties.

Name Description Reflects
for
The id of the element the popover should anchor to.
Type string
open
Whether the popover is currently open.
Type boolean
Default false
noAutoFocus
noautofocus
If true, the popover will not automatically focus the first focusable element when opened.
Type boolean
Default false
trigger
Determines when the popover appears. Multiple triggers can be combined: `click hover focus manual`. When `manual` is included, the popover is fully programmatically controlled.
Type
AfpTrigger
Name Description
HOVER
Hover trigger generated when the user hovers over an element.
FOCUS
Focus trigger generated when an element gains focus.
CLICK
Click trigger generated when an element is clicked.
MANUAL
Manual trigger that requires explicit control.
AfpTrigger
Default [AfpTrigger.CLICK]
strategy
Positioning strategy for the popover. Either `absolute` or `fixed`.
Type
AfpStrategy
Name Description
ABSOLUTE
Positioning using absolute positioning.
FIXED
Positioning using fixed positioning.
AfpStrategy
Default AfpStrategy.ABSOLUTE
placement
The preferred placement of the popover. Note that the actual placement may vary as needed to keep the panel inside of the viewport. If set to an empty array ([]), it enables auto placement. If containing more than two items, it is automatically restricted to the provided placements. You can also input a space-separated string.
Type
AfpPlacement
Name Description
TOP
Top placement.
RIGHT
Right placement.
BOTTOM
Bottom placement.
LEFT
Left placement.
TOP_START
Top-start placement.
TOP_END
Top-end placement.
RIGHT_START
Right-start placement.
RIGHT_END
Right-end placement.
BOTTOM_START
Bottom-start placement.
BOTTOM_END
Bottom-end placement.
LEFT_START
Left-start placement.
LEFT_END
Left-end placement.
AfpPlacement
Default []
matchWidth
matchwidth
If true, the popover will match the width of its anchor element.
Type boolean
Default false
offset
Offset configuration for positioning.
Type
AfpOffset
Name Description
mainAxis
type: number
crossAxis
type: number
alignmentAxis
type: number | null
AfpOffset
Default { mainAxis: 8, crossAxis: 0, alignmentAxis: 0, }
duration
Animation duration in milliseconds.
Type number
Default 150
hoverDelay
hoverdelay
Delay in milliseconds before closing on hover out.
Type number
Default 150

Methods

Learn more about using methods.

Name Description Arguments
show
Opens the popover programmatically.
Return void
-
hide
Closes the popover programmatically and restores focus to the anchor if not in `"manual"` mode.
Return void
-
toggle
Toggles the popover open or closed programmatically.
Return void
-

Events

Learn more about events.

Name Return Description
afp-show void
Emitted when the popover is shown.
afp-after-show void
Emitted after the popover has been shown.
afp-hide void
Emitted when the popover is hidden.
afp-after-hide void
Emitted after the popover has been hidden.

Slots

Learn more about slots.

Name Description
default
The default slot containing the popover’s content.

CSS Parts

Learn more about CSS Parts.

Name Description Selector
base
The popover container element.
::part(base)

CSS Custom Properties

Name Description Default
--afp-popover-scale
The scale of the popover when closed.
0.9

Importing

Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.

import '@afp-design-system/core/dist/components/popover/popover.js';
Share
Create a link with a predefined theme that is automatically applied when the generated link is opened. Default LBBW Presentation Mode
Abort Copy Link