Skip to content

Commit cb38744

Browse files
patrickhlaukemdo
andauthored
Tweak toast docs (#33810)
* Tweak toast docs - a few rewordings/tweaks - add info about toasts with focusable/actionable controls (shouldn't autohide them) * Update site/content/docs/5.0/components/toasts.md Co-authored-by: Mark Otto <[email protected]> * Update site/content/docs/5.0/components/toasts.md Co-authored-by: Mark Otto <[email protected]> Co-authored-by: Mark Otto <[email protected]>
1 parent c2ff225 commit cb38744

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

site/content/docs/5.0/components/toasts.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Toasts are as flexible as you need and have very little required markup. At a mi
4343

4444
### Live
4545

46-
Click the button the below to show as toast (positioning with our utilities in the lower right corner) that has been hidden by default with `.hide`.
46+
Click the button below to show a toast (positioned with our utilities in the lower right corner) that has been hidden by default with `.hide`.
4747

4848
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 5">
4949
<div id="liveToast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true">
@@ -83,7 +83,7 @@ Click the button the below to show as toast (positioning with our utilities in t
8383

8484
### Translucent
8585

86-
Toasts are slightly translucent, too, so they blend over whatever they might appear over.
86+
Toasts are slightly translucent to blend in with what's below them.
8787

8888
{{< example class="bg-dark" >}}
8989
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
@@ -133,7 +133,7 @@ You can stack toasts by wrapping them in a toast container, which will verticall
133133

134134
### Custom content
135135

136-
Customize your toasts by removing sub-components, tweaking with [utilities]({{< docsref "/utilities/api" >}}), or adding your own markup. Here we've created a simpler toast by removing the default `.toast-header`, adding a custom hide icon from [Bootstrap Icons]({{< param icons >}}), and using some [flexbox utilities]({{< docsref "/utilities/flex" >}}) to adjust the layout.
136+
Customize your toasts by removing sub-components, tweaking them with [utilities]({{< docsref "/utilities/api" >}}), or by adding your own markup. Here we've created a simpler toast by removing the default `.toast-header`, adding a custom hide icon from [Bootstrap Icons]({{< param icons >}}), and using some [flexbox utilities]({{< docsref "/utilities/flex" >}}) to adjust the layout.
137137

138138
{{< example class="bg-light" >}}
139139
<div class="toast align-items-center" role="alert" aria-live="assertive" aria-atomic="true">
@@ -274,13 +274,13 @@ You can also get fancy with flexbox utilities to align toasts horizontally and/o
274274

275275
## Accessibility
276276

277-
Toasts are intended to be small interruptions to your visitors or users, so to help those with screen readers and similar assistive technologies, you should wrap your toasts in an [`aria-live` region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions). Changes to live regions (such as injecting/updating a toast component) are automatically announced by screen readers without needing to move the user's focus or otherwise interrupt the user. Additionally, include `aria-atomic="true"` to ensure that the entire toast is always announced as a single (atomic) unit, rather than announcing what was changed (which could lead to problems if you only update part of the toast's content, or if displaying the same toast content at a later point in time). If the information needed is important for the process, e.g. for a list of errors in a form, then use the [alert component]({{< docsref "/components/alerts" >}}) instead of toast.
277+
Toasts are intended to be small interruptions to your visitors or users, so to help those with screen readers and similar assistive technologies, you should wrap your toasts in an [`aria-live` region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions). Changes to live regions (such as injecting/updating a toast component) are automatically announced by screen readers without needing to move the user's focus or otherwise interrupt the user. Additionally, include `aria-atomic="true"` to ensure that the entire toast is always announced as a single (atomic) unit, rather than just announcing what was changed (which could lead to problems if you only update part of the toast's content, or if displaying the same toast content at a later point in time). If the information needed is important for the process, e.g. for a list of errors in a form, then use the [alert component]({{< docsref "/components/alerts" >}}) instead of toast.
278278

279279
Note that the live region needs to be present in the markup *before* the toast is generated or updated. If you dynamically generate both at the same time and inject them into the page, they will generally not be announced by assistive technologies.
280280

281281
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.
282282

283-
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.
283+
As the content you're displaying changes, be sure to update the [`delay` timeout](#options) so that users have enough time to read the toast.
284284

285285
```html
286286
<div class="toast" role="alert" aria-live="polite" aria-atomic="true" data-bs-delay="10000">
@@ -304,6 +304,8 @@ When using `autohide: false`, you must add a close button to allow users to dism
304304
</div>
305305
{{< /example >}}
306306

307+
While technically it's possible to add focusable/actionable controls (such as additional buttons or links) in your toast, you should avoid doing this for autohiding toasts. Even if you give the toast a long [`delay` timeout](#options), keyboard and assistive technology users may find it difficult to reach the toast in time to take action (since toasts don't receive focus when they are displayed). If you absolutely must have further controls, we recommend using a toast with `autohide: false`.
308+
307309
## Sass
308310

309311
### Variables

0 commit comments

Comments
 (0)