You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `triggerElement` property accepts an `HTMLElement` or a `VirtualTrigger` from which to position the Overlay.
271
301
272
302
- You can import the `VirtualTrigger` class from the overlay package to create a virtual trigger that can be used to position an Overlay. This is useful when you want to position an Overlay relative to a point on the screen that is not an element in the DOM, like the mouse cursor.
273
303
304
+
#### type
305
+
274
306
The `type` of an Overlay outlines a number of things about the interaction model within which it works:
The `type` of an Overlay outlines a number of things about the interaction model within which it works:
83
81
84
-
`'inline'` type inserts the overlay after the trigger in the tab order. This creates a natural flow where:
82
+
**Note:** The `type` attribute only affects click-triggered overlays. Hover overlays always use `hint` type behavior, and longpress overlays always use `auto` type behavior. For more control over hover and longpress overlay types, use `<sp-overlay>` directly.
`'modal'` Overlays create a modal context that traps focus within the content and prevents interaction with the rest of the page. The overlay manages focus trapping and accessibility features like `aria-modal="true"` to ensure proper screen reader behavior.
89
+
90
+
They should be used when you need to ensure that the user has interacted with the content of the Overlay before continuing with their work. This is commonly used for dialogs that require a user to confirm or cancel an action before continuing.
`'replace'`type inserts the overlay as if it were the trigger itself in the tab order. This means:
124
+
`'page'`Overlays behave similarly to `'modal'` Overlays by creating a modal context and trapping focus, but they will not be allowed to close via the "light dismiss" algorithm (e.g. the Escape key).
106
125
107
-
- Forward tab: Goes to the next logical element
108
-
- Backward tab (shift): Goes to the element before the trigger
126
+
A page overlay could be used for a full-screen menu on a mobile website. When the user clicks on the menu button, the entire screen is covered with the menu options.
109
127
110
128
```html
111
-
<overlay-triggertype="replace"placement="bottom">
112
-
<sp-buttonslot="trigger">Show Details</sp-button>
113
-
<sp-popoverslot="click-content">
114
-
<sp-dialog>
115
-
<p>Details panel that replaces trigger in tab order</p>
`'hint'` Overlays are much like tooltips so they are not just ephemeral, but they are delivered primarily as a visual helper and exist outside of the tab order. In this way, be sure _not_ to place interactive content within this type of Overlay.
147
+
148
+
This overlay type does not accept focus and does not interfere with the user's interaction with the rest of the page.
149
+
150
+
```html
151
+
<overlay-triggertype="hint"triggered-by="hover">
152
+
<sp-buttonslot="trigger">Open hint</sp-button>
153
+
<sp-tooltipslot="click-content">
154
+
I am a hint type overlay. I am not interactive and will close when the
155
+
user interacts with the page.
156
+
</sp-tooltip>
157
+
</overlay-trigger>
158
+
```
159
+
160
+
</sp-tab-panel>
161
+
<sp-tabvalue="auto">Auto</sp-tab>
162
+
<sp-tab-panelvalue="auto">
163
+
164
+
`'auto'` Overlays provide a place for content that is ephemeral _and_ interactive. These Overlays can accept focus and remain open while interacting with their content. They will close when focus moves outside the overlay or when clicking elsewhere on the page.
`'manual'` Overlays act much like `'auto'` Overlays, but do not close when losing focus or interacting with other parts of the page.
129
183
130
-
`'modal'`type creates a separate tab order and traps focus within the overlay content until the required interaction is complete. This is ideal for important interactions that need user attention.
184
+
Note: When a `'manual'`Overlay is at the top of the "overlay stack", it will still respond to the Escape key and close.
0 commit comments