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
Copy file name to clipboardExpand all lines: packages/tray/README.md
+40-5Lines changed: 40 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@
7
7
[](https://www.npmjs.com/package/@spectrum-web-components/tray)
8
8
[](https://bundlephobia.com/result?p=@spectrum-web-components/tray)
9
9
10
-
```bash
10
+
```zsh
11
11
yarn add @spectrum-web-components/tray
12
12
```
13
13
@@ -71,9 +71,9 @@ A tray has a single default `slot`.
71
71
72
72
`<sp-tray>` presents a page blocking experience and should be opened with the `Overlay` API using the `modal` interaction to ensure that the content appropriately manages the presence of other content in the tab order of the page and the availability of that content for a screen reader.
73
73
74
-
#### Mobile screen reader support
74
+
#### Auto-detection behavior
75
75
76
-
The `<sp-tray>`component automatically includes visually hidden dismiss buttons before and after its content to support mobile screen readers. This is particularly important for VoiceOver on iOS, where users navigate through interactive elements sequentially.
76
+
By default, `<sp-tray>` automatically detects whether its slotted content includes keyboard-accessible dismiss buttons (like `<sp-button>`, `<sp-close-button>`, or HTML `<button>` elements). When no dismiss buttons are found, the tray renders visually hidden dismiss buttons before and after its content to support mobile screen readers, particularly VoiceOver on iOS where users navigate through interactive elements sequentially.
77
77
78
78
These built-in dismiss buttons:
79
79
@@ -84,7 +84,11 @@ These built-in dismiss buttons:
84
84
85
85
This dismiss helper pattern is also implemented in the [`<sp-picker>`](https://opensource.adobe.com/spectrum-web-components/components/picker/) component, which uses the same approach when rendering menu content in a tray on mobile devices.
86
86
87
-
Simply place your content inside the tray - the dismiss buttons are automatically rendered:
<sp-tabvalue="auto">Content has no buttons</sp-tab>
89
+
<sp-tab-panelvalue="auto">
90
+
91
+
This example shows the default behavior where the tray automatically detects that the menu content lacks dismiss buttons and renders visually hidden helpers. Screen readers will announce them as "Dismiss, button."
88
92
89
93
```html
90
94
<overlay-triggertype="modal">
@@ -100,16 +104,47 @@ Simply place your content inside the tray - the dismiss buttons are automaticall
100
104
</sp-menu>
101
105
</sp-tray>
102
106
</overlay-trigger>
107
+
```
108
+
109
+
</sp-tab-panel>
110
+
<sp-tabvalue="with-buttons">Content has buttons</sp-tab>
111
+
<sp-tab-panelvalue="with-buttons">
112
+
113
+
This example shows auto-detection recognizing that the dialog has its own dismiss functionality, so no additional helpers are rendered.
Set `has-keyboard-dismiss` (or `has-keyboard-dismiss="true"`) to prevent the tray from rendering visually hidden dismiss helpers, even when no buttons are detected. You are then responsible for ensuring that your tray content has keyboard-accessible dismiss functionality.
134
+
135
+
```html
136
+
<overlay-triggertype="modal">
137
+
<sp-buttonslot="trigger"variant="secondary">
138
+
Toggle without helpers
139
+
</sp-button>
140
+
<sp-trayslot="click-content"has-keyboard-dismiss>
141
+
<p>
142
+
Custom content that should have custom dismiss functionality, even
143
+
though the tray didn't detect buttons in this slot.
0 commit comments