Toasts

Push notifications to your visitors with a toast, a lightweight and easily customizable alert message.

html
<button class="btn btn-pink" id="show-toast">Show Toast</button>
html
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
  <div id="live-toast" class="toast bg-dark text-white" role="alert" aria-live="assertive" aria-atomic="true">
    <div class="toast-header bg-dark">
      <img src="https://materialstyle.github.io/assets/images/MSIconNewColorV2.svg" class="rounded me-2"
           alt="Material Style Icon" width="20">
      <strong class="me-auto text-white">Material Style</strong>
      <small class="text-white">just now</small>
      <button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="Close">
      </button>
    </div>
    <div class="toast-body">
      Hello, world! This is a toast message.
    </div>
  </div>
</div>

Stacking

You can stack toasts by wrapping them in a .toast-container, which will vertically add some spacing.

html
<button class="btn btn-pink" id="show-stacked-toasts">Show stacked toasts</button>
html
<div class="toast-container position-fixed top-0 end-0 p-3">
  <div id="stacked-toast-1" class="toast bg-white" role="alert" aria-live="assertive" aria-atomic="true">
    <div class="toast-header text-bg-green">
      <img src="https://materialstyle.github.io/assets/images/MSIconNewColorV2.svg" 
           class="rounded me-2" alt="Material Style Icon" width="20">
      <strong class="me-auto">Bootstrap</strong>
      <small class="text-white">just now</small>
      <button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="Close"></button>
    </div>
    <div class="toast-body">
      See? Just like this.
    </div>
  </div>

  <div id="stacked-toast-2" class="toast bg-white" role="alert" aria-live="assertive" aria-atomic="true">
    <div class="toast-header text-bg-indigo">
      <img src="https://materialstyle.github.io/assets/images/MSIconNewColorV2.svg" 
           class="rounded me-2" alt="Material Style Icon" width="20">
      <strong class="me-auto">Bootstrap</strong>
      <small class="text-white">just now</small>
      <button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="Close"></button>
    </div>
    <div class="toast-body">
      Heads up, toasts will stack automatically
    </div>
  </div>
</div>

Javascript

var toastTrigger = document.getElementById('show-toast')
var toastLiveExample = document.getElementById('live-toast')
if (toastTrigger) {
  toastTrigger.addEventListener('click', function () {
    var toast = new materialstyle.Toast(toastLiveExample)

    toast.show()
  })
}

With jQuery

$('#show-toast').on('click', function () {
  $('.toast').toast('show');
});
We are aware that the documentation is incomplete. While we work on it, You may refer to Bootstrap docs or help us by contributing.