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
* chore: remove toast priority queue
* reverse the order so dom order is correct by default
* remove counter from toasts
* remove priority references
* fix verdaccio
* turn on verdaccio
* Revert "turn on verdaccio"
This reverts commit 18b4975.
There is no built in way to display toast notifications in HTML. <TypeLinklinks={docs.links}type={docs.exports.useToastRegion} /> and <TypeLinklinks={docs.links}type={docs.exports.useToast} /> help achieve accessible toasts that can be styled as needed.
49
49
50
50
***Accessible** – Toasts follow the [ARIA alertdialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/). They are rendered in a [landmark region](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/), which keyboard and screen reader users can easily jump to when an alert is announced.
51
-
***Focus management** – When a toast unmounts, focus is moved to the next toast if any. Otherwise, focus is restored to where it was before navigating to the toast region.
52
-
***Priority queue** – Toasts are displayed according to a priority queue, displaying a configurable number of toasts at a time. The queue can either be owned by a provider component, or global.
51
+
***Focus management** – When a toast unmounts, focus is moved to the next toast if any. Otherwise, focus is restored to where it was before navigating to the toast region. Tabbing through the Toast region will move from newest to oldest.
53
52
54
53
## Anatomy
55
54
56
55
<Anatomyrole="img"aria-label="Toast anatomy diagram, showing the toast's title and close button within the toast region." />
57
56
58
-
A toast region is an [ARIA landmark region](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/) labeled "Notifications" by default. A toast region contains one or more visible toasts, in priority order. When the limit is reached, additional toasts are queued until the user dismisses one. Each toast is a non-modal ARIA [alertdialog](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/), containing the content of the notification and a close button.
57
+
A toast region is an [ARIA landmark region](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/) labeled "Notifications" by default. A toast region contains one or more visible toasts, in chronological order. When the limit is reached, additional toasts are queued until the user dismisses one. Each toast is a non-modal ARIA [alertdialog](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/), containing the content of the notification and a close button.
59
58
60
59
Landmark regions including the toast container can be navigated using the keyboard by pressing the <Keyboard>F6</Keyboard> key to move forward, and the <Keyboard>Shift</Keyboard> + <Keyboard>F6</Keyboard> key to move backward. This provides an easy way for keyboard users to jump to the toasts from anywhere in the app. When the last toast is closed, keyboard focus is restored.
The following examples show how to use the `ToastProvider` component created in the above example.
233
232
234
-
### Toast priorities
235
-
236
-
Toasts are displayed according to a priority queue. The priority of a toast can be set using the `priority` option, passed to the `state.add` function. Priorities are arbitrary numbers defined by your implementation.
<ButtononPress={() =>state.add('Toast is done!', {priority: 2})}>
248
-
{/*- end highlight -*/}
249
-
Show medium priority toast
250
-
</Button>
251
-
{/*- begin highlight -*/}
252
-
<ButtononPress={() =>state.add('Toast is burned!', {priority: 3})}>
253
-
{/*- end highlight -*/}
254
-
Show high priority toast
255
-
</Button>
256
-
</>)}
257
-
</ToastProvider>
258
-
```
259
-
260
233
### Auto-dismiss
261
234
262
235
Toasts support a `timeout` option to automatically hide them after a certain amount of time. For accessibility, toasts should have a minimum timeout of 5 seconds to give users enough time to read them. If a toast includes action buttons or other interactive elements it should not auto dismiss. In addition, timers will automatically pause when the user focuses or hovers over a toast.
@@ -267,7 +240,7 @@ Be sure only to automatically dismiss toasts when the information is not importa
267
240
<ToastProvider>
268
241
{state=> (
269
242
///- begin highlight -///
270
-
<ButtononPress={() =>state.add('Toast is done!', {timeout: 5000})}>
243
+
<ButtononPress={() =>state.add('Toast still toasting!', {timeout: 5000})}>
Copy file name to clipboardExpand all lines: packages/react-aria-components/docs/Toast.mdx
+4-4
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ export function App() {
84
84
Then, you can trigger a toast from anywhere using the exported `queue`.
85
85
86
86
```tsx example
87
-
<Button
87
+
<Button
88
88
onPress={() =>queue.add({
89
89
title: 'Toast complete!',
90
90
description: 'Great success.'
@@ -158,7 +158,7 @@ Then, you can trigger a toast from anywhere using the exported `queue`.
158
158
color: white;
159
159
padding: 0;
160
160
outline: none;
161
-
161
+
162
162
&[data-focus-visible] {
163
163
box-shadow: 0002pxslateblue, 0004pxwhite;
164
164
}
@@ -183,7 +183,7 @@ There is no built in way to display toast notifications in HTML. `<ToastRegion>`
183
183
184
184
<Anatomyrole="img"aria-label="Toast anatomy diagram, showing the toast's title and close button within the toast region." />
185
185
186
-
A `<ToastRegion>` is an [ARIA landmark region](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/) labeled "Notifications" by default. A `<ToastRegion>` accepts a function to render one or more visible toasts, in priority order. When the limit is reached, additional toasts are queued until the user dismisses one. Each `<Toast>` is a non-modal ARIA [alertdialog](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/), containing the content of the notification and a close button.
186
+
A `<ToastRegion>` is an [ARIA landmark region](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/) labeled "Notifications" by default. A `<ToastRegion>` accepts a function to render one or more visible toasts, in chronological order. When the limit is reached, additional toasts are queued until the user dismisses one. Each `<Toast>` is a non-modal ARIA [alertdialog](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/), containing the content of the notification and a close button.
187
187
188
188
Landmark regions including the toast container can be navigated using the keyboard by pressing the <Keyboard>F6</Keyboard> key to move forward, and the <Keyboard>Shift</Keyboard> + <Keyboard>F6</Keyboard> key to move backward. This provides an easy way for keyboard users to jump to the toasts from anywhere in the app. When the last toast is closed, keyboard focus is restored.
189
189
@@ -210,7 +210,7 @@ Toasts support a `timeout` option to automatically hide them after a certain amo
210
210
Be sure only to automatically dismiss toasts when the information is not important, or may be found elsewhere. Some users may require additional time to read a toast message, and screen zoom users may miss toasts entirely.
211
211
212
212
```tsx example
213
-
<Button
213
+
<Button
214
214
/*- begin highlight -*/
215
215
onPress={() =>queue.add({title: 'Toast is done!'}, {timeout: 5000})}
0 commit comments