toasts.mdx 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ---
  2. title: Toasts
  3. summary: Toasts are lightweight alert boxes which display for a few seconds after a user has taken an action, to inform them of the state or outcome. They can be used when a user clicks a button or submits a form and their aim is to provide feedback, rather than encourage to take action.
  4. bootstrapLink: components/toasts/
  5. description: Display lightweight alert notifications.
  6. ---
  7. ## Default markup
  8. Use the default toast message to inform users of the outcome of their action and provide additional information. It contains an `x` close button to make it possible for users to close the toast if they wish.
  9. ```html example code
  10. <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false" data-bs-toggle="toast">
  11. <div class="toast-header">
  12. <span class="avatar avatar-xs me-2" style="background-image: url(/samples/avatars/018f.jpg)"></span>
  13. <strong class="me-auto">Mallory Hulme</strong>
  14. <small>11 mins ago</small>
  15. <button type="button" class="ms-2 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  16. </div>
  17. <div class="toast-body">
  18. Hello, world! This is a toast message.
  19. </div>
  20. </div>
  21. ```
  22. ## Translucent
  23. Toasts blend over the elements they appear over. If a browser supports the `backdrop-filter` CSS property, the elements under a toast will be blurred.
  24. ```html example code
  25. <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false" data-bs-toggle="toast">
  26. <div class="toast-header">
  27. <span class="avatar avatar-xs me-2" style="background-image: url(/samples/avatars/029m.jpg)"></span>
  28. <strong class="me-auto">Mallory Hulme</strong>
  29. <small>11 mins ago</small>
  30. <button type="button" class="ms-2 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  31. </div>
  32. <div class="toast-body">
  33. Hello, world! This is a toast message.
  34. </div>
  35. </div>
  36. ```
  37. ## Stacking toasts
  38. Stack multiple toasts together by putting them within one `.toast-container`.
  39. ```html example height="260px"
  40. <div class="toast-container">
  41. <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false" data-bs-toggle="toast">
  42. <div class="toast-header">
  43. <span class="avatar avatar-xs me-2" style="background-image: url(/samples/avatars/008m.jpg)"></span>
  44. <strong class="me-auto">Dunn Slane</strong>
  45. <small>11 mins ago</small>
  46. <button type="button" class="ms-2 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  47. </div>
  48. <div class="toast-body">
  49. Hello, world! This is a toast message.
  50. </div>
  51. </div>
  52. <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false" data-bs-toggle="toast">
  53. <div class="toast-header">
  54. <span class="avatar avatar-xs me-2" style="background-image: url(/samples/avatars/020m.jpg)"></span>
  55. <strong class="me-auto">Mallory Hulme</strong>
  56. <small>7 mins ago</small>
  57. <button type="button" class="ms-2 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  58. </div>
  59. <div class="toast-body">
  60. This is another toast message.
  61. </div>
  62. </div>
  63. </div>
  64. ```