-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Boom toasted #27155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Boom toasted #27155
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e9a04a2
- add more information about accessibility requirement on toast compo…
Lausselloic 9adca75
add a close button to visual test and move to a close function the re…
Lausselloic 095cfed
attach click event listener onto close component outside of the compl…
Lausselloic 58a999f
apply accessibility recommendation on the sample components
Lausselloic 3f1bb51
move close method as private, create a private method to setlisteners…
Lausselloic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 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">×</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 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">×</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 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">×</span> | ||
</button> | ||
</div> | ||
<div class="toast-body"> | ||
See? Just like this. | ||
</div> | ||
</div> | ||
|
||
<div class="toast"> | ||
<div 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">×</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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may be more terse and unambiguous at the end to say: ...use |
||
|
||
{% 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">×</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 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">×</span> | ||
</button> | ||
</div> | ||
<div class="toast-body"> | ||
See? Just like this. | ||
</div> | ||
</div> | ||
|
||
<div class="toast"> | ||
<div 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">×</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 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">×</span> | ||
</button> | ||
</div> | ||
<div class="toast-body"> | ||
Hello, world! This is a toast message. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"to let users" (plural i'd say)"
Also, I wouldn't say it's necessarily an accessibility improvement. toasts/notifications that appear, are announced, and autohide are common and well supported by AT. there ARE some aspects, like users with cognitive disabilities or users that employ screen magnification without AT capabilities that may have issues with toasts, but that's a much larger discussion than just saying "don't hide it". those users would generally benefit more from explicit alert dialogs rather than toasts (dialogs that are modal, and shift focus to the dialog, etc)