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
docs: Toast/TabsPicker docs fixes, prevent Autocomplete input focus on mobile (#9243)
* update Toast examples to work when user is on tailwind
* hide asterix from screenreaders if required is applied to the field already
still needed for cases like Picker since those dont support aria-invalid since they are buttons
* add default class name to tab picker so it doesnt pick up react-aria-select styles
* only focus autocomplete input field if click or keyboard
---------
Co-authored-by: Devon Govett <[email protected]>
Use the `"title"` and `"description"` slots within `<ToastContent>` to provide structured content for the toast. The title is required, and description is optional.
73
73
74
-
```tsx render hideImports
75
-
"use client";
76
-
import {queue} from'vanilla-starter/Toast';
77
-
import {Button} from'vanilla-starter/Button';
78
-
79
-
function Example() {
80
-
return (
81
-
<Button
82
-
///- begin highlight -///
83
-
onPress={() =>queue.add({
84
-
title: 'Update available',
85
-
description: 'A new version is ready to install.'
86
-
})}
87
-
///- end highlight -///
88
-
>
89
-
Check for updates
90
-
</Button>
91
-
);
92
-
}
93
-
```
74
+
<ExampleSwitcher>
75
+
```tsx render hideImports type="vanilla"
76
+
"use client";
77
+
import {queue} from'vanilla-starter/Toast';
78
+
import {Button} from'vanilla-starter/Button';
79
+
80
+
function Example() {
81
+
return (
82
+
<Button
83
+
///- begin highlight -///
84
+
onPress={() =>queue.add({
85
+
title: 'Update available',
86
+
description: 'A new version is ready to install.'
87
+
})}
88
+
///- end highlight -///
89
+
>
90
+
Check for updates
91
+
</Button>
92
+
);
93
+
}
94
+
```
95
+
96
+
```tsx render hideImports type="tailwind"
97
+
"use client";
98
+
import {queue} from'tailwind-starter/Toast';
99
+
import {Button} from'tailwind-starter/Button';
100
+
101
+
function Example() {
102
+
return (
103
+
<Button
104
+
///- begin highlight -///
105
+
onPress={() =>queue.add({
106
+
title: 'Update available',
107
+
description: 'A new version is ready to install.'
108
+
})}
109
+
///- end highlight -///
110
+
>
111
+
Check for updates
112
+
</Button>
113
+
);
114
+
}
115
+
```
116
+
117
+
</ExampleSwitcher>
94
118
95
119
### Close button
96
120
@@ -105,26 +129,50 @@ Include a `<Button slot="close">` to allow users to dismiss the toast manually.
105
129
106
130
Use the `timeout` option to automatically dismiss toasts after a period of time. For accessibility, toasts should have a minimum timeout of **5 seconds**. Timers automatically pause when the user focuses or hovers over a toast.
107
131
108
-
```tsx render hideImports
109
-
"use client";
110
-
import {queue} from'vanilla-starter/Toast';
111
-
import {Button} from'vanilla-starter/Button';
112
-
113
-
function Example() {
114
-
return (
115
-
<Button
116
-
///- begin highlight -///
117
-
onPress={() =>queue.add(
118
-
{title: 'File has been saved!'},
119
-
{timeout: 5000}
120
-
)}
121
-
///- end highlight -///
122
-
>
123
-
Save file
124
-
</Button>
125
-
);
126
-
}
127
-
```
132
+
<ExampleSwitcher>
133
+
```tsx render hideImports type="vanilla"
134
+
"use client";
135
+
import {queue} from'vanilla-starter/Toast';
136
+
import {Button} from'vanilla-starter/Button';
137
+
138
+
function Example() {
139
+
return (
140
+
<Button
141
+
///- begin highlight -///
142
+
onPress={() =>queue.add(
143
+
{title: 'File has been saved!'},
144
+
{timeout: 5000}
145
+
)}
146
+
///- end highlight -///
147
+
>
148
+
Save file
149
+
</Button>
150
+
);
151
+
}
152
+
```
153
+
154
+
```tsx render hideImports type="tailwind"
155
+
"use client";
156
+
import {queue} from'tailwind-starter/Toast';
157
+
import {Button} from'tailwind-starter/Button';
158
+
159
+
function Example() {
160
+
return (
161
+
<Button
162
+
///- begin highlight -///
163
+
onPress={() =>queue.add(
164
+
{title: 'File has been saved!'},
165
+
{timeout: 5000}
166
+
)}
167
+
///- end highlight -///
168
+
>
169
+
Save file
170
+
</Button>
171
+
);
172
+
}
173
+
```
174
+
175
+
</ExampleSwitcher>
128
176
129
177
<InlineAlertvariant="notice">
130
178
<Heading>Accessibility</Heading>
@@ -135,35 +183,68 @@ function Example() {
135
183
136
184
Toasts can be programmatically dismissed using the key returned from `queue.add()`. This is useful when a toast becomes irrelevant before the user manually closes it.
0 commit comments