@@ -24,11 +24,14 @@ A basic toast can include a header (though it doesn't strictly need one) with wh
24
24
25
25
<div class =" bg-light " >
26
26
{% capture example %}
27
- <div class =" toast " >
27
+ <div class =" toast " role = " alert " aria-live = " assertive " aria-atomic = " true " >
28
28
<div class =" toast-header " >
29
29
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
30
30
<strong class="mr-auto">Bootstrap</strong>
31
31
<small>11 mins ago</small>
32
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
33
+ <span aria-hidden="true">×</span>
34
+ </button>
32
35
</div >
33
36
<div class =" toast-body " >
34
37
Hello, world! This is a toast message.
@@ -42,11 +45,14 @@ They're slightly translucent, too, so they blend over whatever they might appear
42
45
43
46
<div class =" bg-dark " >
44
47
{% capture example %}
45
- <div class =" toast " >
48
+ <div class =" toast " role = " alert " aria-live = " assertive " aria-atomic = " true " >
46
49
<div class =" toast-header " >
47
50
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
48
51
<strong class="mr-auto">Bootstrap</strong>
49
52
<small class="text-muted">11 mins ago</small>
53
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
54
+ <span aria-hidden="true">×</span>
55
+ </button>
50
56
</div >
51
57
<div class =" toast-body " >
52
58
Hello, world! This is a toast message.
@@ -60,22 +66,28 @@ Plus, they'll easily stack.
60
66
61
67
<div class =" bg-light " >
62
68
{% capture example %}
63
- <div class =" toast " >
69
+ <div class =" toast " role = " alert " aria-live = " assertive " aria-atomic = " true " >
64
70
<div class =" toast-header " >
65
71
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
66
72
<strong class="mr-auto">Bootstrap</strong>
67
73
<small class="text-muted">just now</small>
74
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
75
+ <span aria-hidden="true">×</span>
76
+ </button>
68
77
</div >
69
78
<div class =" toast-body " >
70
79
See? Just like this.
71
80
</div >
72
81
</div >
73
82
74
- <div class =" toast " >
83
+ <div class =" toast " role = " alert " aria-live = " assertive " aria-atomic = " true " >
75
84
<div class =" toast-header " >
76
85
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
77
86
<strong class="mr-auto">Bootstrap</strong>
78
87
<small class="text-muted">2 seconds ago</small>
88
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
89
+ <span aria-hidden="true">×</span>
90
+ </button>
79
91
</div >
80
92
<div class =" toast-body " >
81
93
Heads up, toasts will stack automatically
@@ -88,10 +100,12 @@ Plus, they'll easily stack.
88
100
## Accessibility
89
101
90
102
Toasts are intended to be small interruptions to your visitors or users, so to help those on screen readers, you should wrap your toasts in an [ ` aria-live ` region] ( https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions ) . This allows screen readers the ability to see suggested interruptions without any visual cues.
103
+ To improve accessibility level, we strongly recomend to use ` autohide: false ` and add a ` close ` button into the header to let user dismiss that element.
104
+ You also need to adapt the ` role ` and ` aria-live ` level depending on the content. If it's an important message like error, use an ` alert ` role ` assertive ` otherwise use a role ` status ` with a ` polite ` level.
91
105
92
106
{% highlight html %}
93
- <div role =" region " aria-live =" polite " >
94
- <div class = " toast " >...</div >
107
+ <div role =" alert " aria-live =" assertive " aria-atomic = " true " >
108
+ <div role = " alert " aria-live = " assertive " aria-atomic = " true " >...</div >
95
109
</div >
96
110
{% endhighlight %}
97
111
@@ -107,6 +121,9 @@ Place toasts with custom CSS as you need them. The top right is often used for n
107
121
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
108
122
<strong class="mr-auto">Bootstrap</strong>
109
123
<small>11 mins ago</small>
124
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
125
+ <span aria-hidden="true">×</span>
126
+ </button>
110
127
</div>
111
128
<div class="toast-body">
112
129
Hello, world! This is a toast message.
@@ -126,22 +143,28 @@ For systems that generate more notifications, consider using a wrapping element
126
143
<div style =" position : absolute ; top : 0 ; right : 0 ;" >
127
144
128
145
<!-- Then put toasts within -->
129
- <div class="toast">
146
+ <div class="toast" role="alert" aria-live="assertive" aria-atomic="true" >
130
147
<div class="toast-header">
131
148
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
132
149
<strong class="mr-auto">Bootstrap</strong>
133
150
<small class="text-muted">just now</small>
151
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
152
+ <span aria-hidden="true">×</span>
153
+ </button>
134
154
</div>
135
155
<div class="toast-body">
136
156
See? Just like this.
137
157
</div>
138
158
</div>
139
159
140
- <div class="toast">
160
+ <div class="toast" role="alert" aria-live="assertive" aria-atomic="true" >
141
161
<div class="toast-header">
142
162
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
143
163
<strong class="mr-auto">Bootstrap</strong>
144
164
<small class="text-muted">2 seconds ago</small>
165
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
166
+ <span aria-hidden="true">×</span>
167
+ </button>
145
168
</div>
146
169
<div class="toast-body">
147
170
Heads up, toasts will stack automatically
@@ -162,11 +185,14 @@ You can also get fancy with flexbox utilities.
162
185
<div class =" d-flex justify-content-center " style =" position : absolute ; top : 0 ; right : 0 ; left : 0 ;" >
163
186
164
187
<!-- Then put toasts within -->
165
- <div class="toast">
188
+ <div class="toast" role="alert" aria-live="assertive" aria-atomic="true" >
166
189
<div class="toast-header">
167
190
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
168
191
<strong class="mr-auto">Bootstrap</strong>
169
192
<small>11 mins ago</small>
193
+ <button type="button" class="close" data-dismiss="toast" aria-label="Close" style="">
194
+ <span aria-hidden="true">×</span>
195
+ </button>
170
196
</div>
171
197
<div class="toast-body">
172
198
Hello, world! This is a toast message.
0 commit comments