Skip to content

Commit 482510e

Browse files
LausselloicJohann-S
authored andcommitted
update toast documentation following pull #27155 also remove close button everywhere just let it when autohide is set to false
1 parent 7a8ab46 commit 482510e

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

js/tests/visual/toast.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ <h1>Toast <small>Bootstrap Visual Test</small></h1>
3131
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
3232
<strong class="mr-auto">Bootstrap</strong>
3333
<small>11 mins ago</small>
34-
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
35-
<span aria-hidden="true">&times;</span>
36-
</button>
3734
</div>
3835
<div class="toast-body">
3936
Hello, world! This is a toast message with <strong>autohide</strong> in 2 seconds

site/docs/4.1/components/toasts.md

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ Plus, they'll easily stack.
7171
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
7272
<strong class="mr-auto">Bootstrap</strong>
7373
<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">&times;</span>
76-
</button>
7774
</div>
7875
<div class="toast-body">
7976
See? Just like this.
@@ -85,9 +82,6 @@ Plus, they'll easily stack.
8582
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
8683
<strong class="mr-auto">Bootstrap</strong>
8784
<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">&times;</span>
90-
</button>
9185
</div>
9286
<div class="toast-body">
9387
Heads up, toasts will stack automatically
@@ -99,16 +93,39 @@ Plus, they'll easily stack.
9993

10094
## Accessibility
10195

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.
96+
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. If the information needed is important for the process, e.g. for a list of errors in a form, then use the [alert component]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/alerts/) instead of toast.
97+
98+
You also need to adapt the `role` and `aria-live` level depending on the content. If it's an important message like an error, use `role="alert" aria-live="assertive"`, otherwise use `role="status" aria-live="polite"` attributes.
99+
100+
As the content you're displaying changes, be sure to update the [`delay` timeout](#options) to ensure people have enough time to read the toast.
105101

106102
{% highlight html %}
107-
<div role="alert" aria-live="assertive" aria-atomic="true">
103+
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" data-delay="10000">
108104
<div role="alert" aria-live="assertive" aria-atomic="true">...</div>
109105
</div>
110106
{% endhighlight %}
111107

108+
When using `autohide: false`, you must add a close button to allow users to dismiss the toast.
109+
110+
<div class="bg-light">
111+
{% capture example %}
112+
<div role="alert" aria-live="assertive" aria-atomic="true" class="toast" data-autohide="false">
113+
<div class="toast-header">
114+
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
115+
<strong class="mr-auto">Bootstrap</strong>
116+
<small>11 mins ago</small>
117+
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
118+
<span aria-hidden="true">&times;</span>
119+
</button>
120+
</div>
121+
<div class="toast-body">
122+
Hello, world! This is a toast message.
123+
</div>
124+
</div>
125+
{% endcapture %}
126+
{% include example.html content=example %}
127+
</div>
128+
112129
## Placement
113130

114131
Place toasts with custom CSS as you need them. The top right is often used for notifications, as is the top middle. If you're only ever going to show one toast at a time, put the positioning styles right on the `.toast.`
@@ -121,9 +138,6 @@ Place toasts with custom CSS as you need them. The top right is often used for n
121138
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
122139
<strong class="mr-auto">Bootstrap</strong>
123140
<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">&times;</span>
126-
</button>
127141
</div>
128142
<div class="toast-body">
129143
Hello, world! This is a toast message.
@@ -148,9 +162,6 @@ For systems that generate more notifications, consider using a wrapping element
148162
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
149163
<strong class="mr-auto">Bootstrap</strong>
150164
<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">&times;</span>
153-
</button>
154165
</div>
155166
<div class="toast-body">
156167
See? Just like this.
@@ -162,9 +173,6 @@ For systems that generate more notifications, consider using a wrapping element
162173
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
163174
<strong class="mr-auto">Bootstrap</strong>
164175
<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">&times;</span>
167-
</button>
168176
</div>
169177
<div class="toast-body">
170178
Heads up, toasts will stack automatically
@@ -190,9 +198,6 @@ You can also get fancy with flexbox utilities.
190198
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
191199
<strong class="mr-auto">Bootstrap</strong>
192200
<small>11 mins ago</small>
193-
<button type="button" class="close" data-dismiss="toast" aria-label="Close" style="">
194-
<span aria-hidden="true">&times;</span>
195-
</button>
196201
</div>
197202
<div class="toast-body">
198203
Hello, world! This is a toast message.

0 commit comments

Comments
 (0)