toasts.mdx 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ---
  2. title: Toasts
  3. description: 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. ---
  6. ## Default markup
  7. 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.
  8. ```html example code
  9. <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false" data-bs-toggle="toast">
  10. <div class="toast-header">
  11. <span class="avatar avatar-xs me-2" style="background-image: url(/samples/avatars/018f.jpg)"></span>
  12. <strong class="me-auto">Mallory Hulme</strong>
  13. <small>11 mins ago</small>
  14. <button type="button" class="ms-2 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  15. </div>
  16. <div class="toast-body">
  17. Hello, world! This is a toast message.
  18. </div>
  19. </div>
  20. ```
  21. ## Translucent
  22. 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.
  23. ```html example code
  24. <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false" data-bs-toggle="toast">
  25. <div class="toast-header">
  26. <span class="avatar avatar-xs me-2" style="background-image: url(/samples/avatars/029m.jpg)"></span>
  27. <strong class="me-auto">Mallory Hulme</strong>
  28. <small>11 mins ago</small>
  29. <button type="button" class="ms-2 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  30. </div>
  31. <div class="toast-body">
  32. Hello, world! This is a toast message.
  33. </div>
  34. </div>
  35. ```
  36. ## Stacking toasts
  37. Stack multiple toasts together by putting them within one `.toast-container`.
  38. ```html example code height="260px"
  39. <div class="toast-container">
  40. <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false" data-bs-toggle="toast">
  41. <div class="toast-header">
  42. <span class="avatar avatar-xs me-2" style="background-image: url(/samples/avatars/008m.jpg)"></span>
  43. <strong class="me-auto">Dunn Slane</strong>
  44. <small>11 mins ago</small>
  45. <button type="button" class="ms-2 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  46. </div>
  47. <div class="toast-body">
  48. Hello, world! This is a toast message.
  49. </div>
  50. </div>
  51. <div class="toast show" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false" data-bs-toggle="toast">
  52. <div class="toast-header">
  53. <span class="avatar avatar-xs me-2" style="background-image: url(/samples/avatars/020m.jpg)"></span>
  54. <strong class="me-auto">Mallory Hulme</strong>
  55. <small>7 mins ago</small>
  56. <button type="button" class="ms-2 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
  57. </div>
  58. <div class="toast-body">
  59. This is another toast message.
  60. </div>
  61. </div>
  62. </div>
  63. ```