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
`sp-dialog` displays important information that users need to acknowledge. They appear over the interface and block further interactions. When used directly the `sp-dialog` element surfaces a `slot` based API for deep customization of the content to be included in the overlay.
4
4
5
+
Note: the `sp-dialog` element is a component that is used to create a dialog layout. For modal and popover behavior, it should be used within a component that manages the overlay state.
6
+
5
7
### Usage
6
8
7
9
[](https://www.npmjs.com/package/@spectrum-web-components/dialog)
8
10
[](https://bundlephobia.com/result?p=@spectrum-web-components/dialog)
9
11
[](https://webcomponents.dev/edit/collection/fO75441E1Q5ZlI0e9pgq/RSDikStPmUPSioVpCsYb/src/index.ts)
10
12
11
-
```
13
+
```bash
12
14
yarn add @spectrum-web-components/dialog
13
15
```
14
16
15
17
Import the side effectful registration of `<sp-dialog>` via:
@@ -89,16 +118,14 @@ import { Dialog } from '@spectrum-web-components/dialog';
89
118
</sp-tab-panel>
90
119
</sp-tabs>
91
120
92
-
## Variants
93
-
94
-
### Dismissable
121
+
#### Dismissable
95
122
96
123
When supplied with the `dissmissable` attribute an `<sp-dialog>` element will surface a "close" button afordance that will dispatch a DOM event with the name of `close` when pressed.
97
124
98
125
Note: the `dissmissable` attribute will not be followed when `mode="fullscreen"` or `mode="fullscreenTakeover"` are applies in accordance with the Spectrum specification.
99
126
100
127
```html
101
-
<sp-dialogsize="m"dismissable>
128
+
<sp-dialogdismissable>
102
129
<h2slot="heading">Disclaimer</h2>
103
130
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
104
131
tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris
@@ -113,10 +140,10 @@ Note: the `dissmissable` attribute will not be followed when `mode="fullscreen"`
113
140
</sp-dialog>
114
141
```
115
142
116
-
### No Divider
143
+
####No Divider
117
144
118
145
```html
119
-
<sp-dialogsize="m"dismissableno-divider>
146
+
<sp-dialogdismissableno-divider>
120
147
<h2slot="heading">Disclaimer</h2>
121
148
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
122
149
tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris
@@ -131,24 +158,73 @@ Note: the `dissmissable` attribute will not be followed when `mode="fullscreen"`
131
158
</sp-dialog>
132
159
```
133
160
134
-
### Hero
161
+
### Behaviors
162
+
163
+
Use the dialog with an overlay to create a dialog that appears over the current page. The dialog manages several behaviors:
164
+
165
+
1. Animation of the dialog content when opening/closing
The `receives-focus` attribute can be used to control whether the dialog should receive focus when it is opened. Leverage the `type="modal"` and `receives-focus="auto"` settings in the Overlay API to ensure that focus is thrown into the dialog content when opened and that the tab order will be trapped within it while open.
203
+
204
+
The `receives-focus` attribute on `overlay-trigger` has three possible values:
205
+
206
+
-`auto` (default): Focus will automatically move to the first focusable element in the dialog
207
+
-`true`: Forces focus to move to the overlay content
208
+
-`false`: Prevents focus from moving to the overlay
209
+
210
+
For accessible dialogs, always use `receives-focus="auto"` or `receives-focus="true"` to ensure keyboard users can interact with the dialog content.
0 commit comments