Set for to the id of the element that opens the popover. The trigger and the popover must be in the same document or shadow root. The popover sets aria-haspopup and aria-expanded on its trigger.
For a list of actions, use orb-menu instead. It handles the keyboard and focus the way menus need.
show() opens the popover at a pointer event, or at any object with getBoundingClientRect, such as a Range at a caret. Set contextElement on that object to the scrolling element that contains it, so the popover follows the scroll. Without for, the popover has no trigger, so a press outside it or Escape closes it.
Manual test:
- Click the button. The popover opens next to it. Click the button again, click outside, or press Escape to close it.
- After Escape, focus returns to the button.
| Description |
Renders an arrow pointing to the trigger |
| Attribute |
arrow |
| Type |
boolean |
| Default |
true |
| Description |
The padding between the arrow and the edges of the popover. Useful if you change the border-radius of the popover |
| Attribute |
arrow-padding |
| Type |
number |
| Default |
6 |
| Description |
Execute a callback after the popover has dismissed |
| Attribute |
– |
| Type |
() => void | Promise<void> |
| Default |
undefined |
| Description |
Id of the element that will trigger the popover to open |
| Attribute |
for |
| Type |
string |
| Default |
undefined |
| Description |
Execute a callback before the popover starts presenting |
| Attribute |
– |
| Type |
() => void | Promise<void> |
| Default |
undefined |
| Description |
Horizontal offset used when auto positioning the popover content |
| Attribute |
offset-x |
| Type |
number |
| Default |
0 |
| Description |
Vertical offset used when auto positioning the popover content |
| Attribute |
offset-y |
| Type |
number |
| Default |
10 |
| Description |
Where the popover should be placed |
| Attribute |
placement |
| Type |
"bottom" | "bottom-end" | "bottom-start" | "left" | "left-end" | "left-start" | "right" | "right-end" | "right-start" | "top" | "top-end" | "top-start" |
| Default |
undefined |
| Description |
- click: Popover will show on left click or tap on mobile. - context-menu: Popover will show on right click or press on mobile. - hover: Popover will show on hover or tap on mobile. Clicking the trigger or the content doesn’t dismiss it. It closes when the pointer leaves, or on a click outside. |
| Attribute |
show-on |
| Type |
"click" | "context-menu" | "hover" |
| Default |
"click" |
| Description |
Emits when the popover is closed |
| Type |
CustomEvent<any> |
| Description |
Emits before the popover starts dismissing |
| Type |
CustomEvent<any> |
| Description |
Emits when the popover is opened |
| Type |
CustomEvent<any> |
| Description |
Emits before the popover starts opening |
| Type |
CustomEvent<any> |
| Signature |
hide(role?: string, data?: any) => Promise<void> |
| Parameters |
role (string)
data (any) |
| Description |
Opens the popover. Pass a pointer event, or anything with getBoundingClientRect, such as a Range, to open it there. Calling it again while open moves it. |
| Signature |
show(at?: Anchor) => Promise<void> |
| Parameters |
at (Pick<MouseEvent, "clientX" | "clientY"> | { getBoundingClientRect(): DOMRect; contextElement?: Element; }) |
| Part |
Description |
"arrow" |
|
"content" |
|
graph TD;
orb-cell --> orb-popover
orb-datepicker --> orb-popover
orb-rich-text --> orb-popover
style orb-popover fill:#f9f,stroke:#333,stroke-width:4px