aboutsummaryrefslogtreecommitdiff
path: root/site/docs
diff options
context:
space:
mode:
authorLaussel Loïc <[email protected]>2018-08-31 09:18:28 +0200
committerXhmikosR <[email protected]>2018-11-13 08:47:32 +0200
commit4cac833447c53ec7f140c26260ddf36d78ff298f (patch)
tree7c7b0631c775c79a39949c10d7d9d0bea5761219 /site/docs
parent2f81ab007cad06dd333a7431a3a653f812bbf246 (diff)
downloadbootstrap-4cac833447c53ec7f140c26260ddf36d78ff298f.tar.xz
bootstrap-4cac833447c53ec7f140c26260ddf36d78ff298f.zip
Implement `data-dismiss="toast"` to allow user to interact itself with the component (#27155)
Diffstat (limited to 'site/docs')
-rw-r--r--site/docs/4.1/components/toasts.md44
1 files changed, 35 insertions, 9 deletions
diff --git a/site/docs/4.1/components/toasts.md b/site/docs/4.1/components/toasts.md
index 54e0a1c52..84359084d 100644
--- a/site/docs/4.1/components/toasts.md
+++ b/site/docs/4.1/components/toasts.md
@@ -24,11 +24,14 @@ A basic toast can include a header (though it doesn't strictly need one) with wh
<div class="bg-light">
{% capture example %}
-<div class="toast">
+<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
@@ -42,11 +45,14 @@ They're slightly translucent, too, so they blend over whatever they might appear
<div class="bg-dark">
{% capture example %}
-<div class="toast">
+<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">11 mins ago</small>
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
@@ -60,22 +66,28 @@ Plus, they'll easily stack.
<div class="bg-light">
{% capture example %}
-<div class="toast">
+<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">just now</small>
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
</div>
<div class="toast-body">
See? Just like this.
</div>
</div>
-<div class="toast">
+<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">2 seconds ago</small>
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
</div>
<div class="toast-body">
Heads up, toasts will stack automatically
@@ -88,10 +100,12 @@ Plus, they'll easily stack.
## Accessibility
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.
+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.
+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.
{% highlight html %}
-<div role="region" aria-live="polite">
- <div class="toast">...</div>
+<div role="alert" aria-live="assertive" aria-atomic="true">
+ <div role="alert" aria-live="assertive" aria-atomic="true">...</div>
</div>
{% endhighlight %}
@@ -107,6 +121,9 @@ Place toasts with custom CSS as you need them. The top right is often used for n
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
@@ -126,22 +143,28 @@ For systems that generate more notifications, consider using a wrapping element
<div style="position: absolute; top: 0; right: 0;">
<!-- Then put toasts within -->
- <div class="toast">
+ <div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">just now</small>
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
</div>
<div class="toast-body">
See? Just like this.
</div>
</div>
- <div class="toast">
+ <div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">2 seconds ago</small>
+ <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
</div>
<div class="toast-body">
Heads up, toasts will stack automatically
@@ -162,11 +185,14 @@ You can also get fancy with flexbox utilities.
<div class="d-flex justify-content-center" style="position: absolute; top: 0; right: 0; left: 0;">
<!-- Then put toasts within -->
- <div class="toast">
+ <div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
+ <button type="button" class="close" data-dismiss="toast" aria-label="Close" style="">
+ <span aria-hidden="true">&times;</span>
+ </button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.