Popover
Popovers are containers used to display transient content such as options and actions.
import {PopoverModule} from "@qualcomm-ui/angular/popover"Examples
Simple
Basic popover using the simple API with a label and child content. The anchor and trigger are supplied using directives, while the content is the default slot.
Qualcomm
Composite
Build with the composite API for granular control. This API requires you to provide each subcomponent, but gives you full control over the structure and layout.
Qualcomm
<div q-popover-root>
<div q-popover-anchor>
<button q-button q-popover-trigger variant="outline">Click Me</button>
</div>
<ng-template qPortal>
<div q-popover-positioner>
<div q-popover-content>
<div q-popover-arrow></div>
<div q-popover-label>Label</div>
<div q-popover-description>Description</div>
</div>
</div>
</ng-template>
</div>API
q-popover
The q-popover directive extends the q-popover-root directive with the following props:
| Prop | Type |
|---|---|
Optional description text for the popover. | string |
Set to true to disable portalling behavior for the popup content. | boolean |
Set to true to hide the arrow element. | boolean |
Optional label text for the popover. | string |
Type
stringDescription
Optional description text for the popover.
Type
booleanDescription
Set to true to disable portalling behavior for the popup content.
Type
booleanDescription
Set to true to hide the arrow element.
Type
stringDescription
Optional label text for the popover.
Composite API
q-popover-root
| Prop | Type | Default |
|---|---|---|
Whether to automatically set focus on the first focusable
content within the popover when opened. | boolean | true |
Whether to close the popover when the escape key is pressed. | boolean | true |
Whether to close the popover when the user clicks outside the popover. | boolean | true |
The initial open state of the popover when rendered.
Use when you don't need to control the open state of the popover. | boolean | |
The document's text/writing direction. | 'ltr' | 'rtl' | "ltr" |
A root node to correctly resolve the Document in custom environments. i.e.,
Iframes, Electron. | () => | |
The element to focus on when the popover is opened. | () => HTMLElement | |
Whether the popover should be modal. When set to true:- interaction with outside elements will be disabled - only popover content will be visible to screen readers - scrolling is blocked - focus is trapped within the popover | boolean | false |
The controlled open state of the popover | boolean | |
The persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event | Array< | |
The options used to position the popover content. | PositioningOptions | |
On close, restore focus to the element that triggered the open event. | boolean | true |
Function called when the escape key is pressed | KeyboardEvent | |
Function called when the focus is moved outside the component | CustomEvent<{ | |
Function called when an interaction happens outside the component | | CustomEvent<{event?: E}> | |
Fired when the popover opens or closes. | { | |
Function called when the pointer is pressed down outside the component | CustomEvent<{ | |
Function called when this layer is closed due to a parent layer being closed | CustomEvent<{ |
Type
booleanDescription
Whether to automatically set focus on the first focusable
content within the popover when opened.
Type
booleanDescription
Whether to close the popover when the escape key is pressed.
Type
booleanDescription
Whether to close the popover when the user clicks outside the popover.
Type
booleanDescription
The initial open state of the popover when rendered.
Use when you don't need to control the open state of the popover.
Type
'ltr' | 'rtl'
Description
The document's text/writing direction.
Type
() =>
| Node
| ShadowRoot
| Document
Description
A root node to correctly resolve the Document in custom environments. i.e.,
Iframes, Electron.
Type
() => HTMLElement
Description
The element to focus on when the popover is opened.
Type
booleanDescription
Whether the popover should be modal. When set to
- interaction with outside elements will be disabled
- only popover content will be visible to screen readers
- scrolling is blocked
- focus is trapped within the popover
true:- interaction with outside elements will be disabled
- only popover content will be visible to screen readers
- scrolling is blocked
- focus is trapped within the popover
Type
booleanDescription
The controlled open state of the popover
Type
Array<
() => Element
>
Description
The persistent elements that:
- should not have pointer-events disabled
- should not trigger the dismiss event
- should not have pointer-events disabled
- should not trigger the dismiss event
Type
PositioningOptionsDescription
The options used to position the popover content.
Type
booleanDescription
On close, restore focus to the element that triggered the open event.
Type
KeyboardEventDescription
Function called when the escape key is pressed
Type
CustomEvent<{
event?: E
}>
Description
Function called when the focus is moved outside the component
Type
| CustomEvent<{event?: E}>
| CustomEvent<{event?: E}>
Description
Function called when an interaction happens outside the component
Type
{
open: boolean
}
Description
Fired when the popover opens or closes.
Type
CustomEvent<{
event?: E
}>
Description
Function called when the pointer is pressed down outside the component
Type
CustomEvent<{
originalIndex: number
originalLayer: HTMLElement
targetIndex: number
targetLayer: HTMLElement
}>
Description
Function called when this layer is closed due to a parent layer being closed
This section describes the elements of the Popover's composite API.
q-popover-label
| Prop | Type |
|---|---|
id attribute. If
omitted, a unique identifier will be generated for accessibility.) | string |
Type
stringDescription
id attribute. If
omitted, a unique identifier will be generated for accessibility.)
Data Structures
PopoverPositioningOptions
| Prop | Type | Default |
|---|---|---|
The minimum padding between the arrow and the floating element's corner. | number | 4 |
The overflow boundary of the reference element | () => | |
Whether the popover should fit the viewport. | boolean | |
Whether to flip the placement when the floating element overflows the boundary. | | boolean | true |
Function that returns the anchor rect | ( | |
The main axis offset or gap between the reference and floating element | number | 8 |
Whether the popover should be hidden when the reference element is detached | boolean | |
Options to activate auto-update listeners | | boolean | true |
The offset of the floating element | { | |
Function called when the placement is computed | ( | |
Function called when the floating element is positioned or not | (data: { | |
The virtual padding around the viewport edges to check for overflow | number | |
Whether the floating element can overlap the reference element | boolean | false |
The initial placement of the floating element | | 'bottom' | 'top' |
Whether to make the floating element same width as the reference element | boolean | |
The secondary axis offset or gap between the reference and floating elements | number | |
Whether the popover should slide when it overflows. | boolean | |
The strategy to use for positioning | | 'absolute' | 'absolute' |
A callback that will be called when the popover needs to calculate its
position. | (data: { |
Type
numberDescription
The minimum padding between the arrow and the floating element's corner.
Type
() =>
| 'clippingAncestors'
| Element
| Array<Element>
| {
height: number
width: number
x: number
y: number
}
Description
The overflow boundary of the reference element
Type
booleanDescription
Whether the popover should fit the viewport.
Type
| boolean
| Array<
| 'bottom'
| 'bottom-end'
| 'bottom-start'
| 'left'
| 'left-end'
| 'left-start'
| 'right'
| 'right-end'
| 'right-start'
| 'top'
| 'top-end'
| 'top-start'
>
Description
Whether to flip the placement when the floating element overflows the boundary.
Type
(
element:
| HTMLElement
| VirtualElement,
) => {
height?: number
width?: number
x?: number
y?: number
}
Description
Function that returns the anchor rect
Type
numberDescription
The main axis offset or gap between the reference and floating element
Type
booleanDescription
Whether the popover should be hidden when the reference element is detached
Type
| boolean
| {
ancestorResize?: boolean
ancestorScroll?: boolean
animationFrame?: boolean
elementResize?: boolean
layoutShift?: boolean
}
Description
Options to activate auto-update listeners
Type
{
crossAxis?: number
mainAxis?: number
}
Description
The offset of the floating element
Type
(
data: ComputePositionReturn,
) => void
Description
Function called when the placement is computed
Type
(data: {
placed: boolean
}) => void
Description
Function called when the floating element is positioned or not
Type
numberDescription
The virtual padding around the viewport edges to check for overflow
Type
booleanDescription
Whether the floating element can overlap the reference element
Type
| 'bottom'
| 'bottom-end'
| 'bottom-start'
| 'left'
| 'left-end'
| 'left-start'
| 'right'
| 'right-end'
| 'right-start'
| 'top'
| 'top-end'
| 'top-start'
Description
The initial placement of the floating element
Type
booleanDescription
Whether to make the floating element same width as the reference element
Type
numberDescription
The secondary axis offset or gap between the reference and floating elements
Type
booleanDescription
Whether the popover should slide when it overflows.
Type
| 'absolute'
| 'fixed'
Description
The strategy to use for positioning
Type
(data: {
updatePosition: () => Promise<void>
}) => void | Promise<void>
Description
A callback that will be called when the popover needs to calculate its
position.