Bootstrap JS Toasts

Toast CSS Classes

The Toast component is like an alert box that is only shown for a couple of seconds when something happens (i.e. when the user clicks on a button, submits a form, etc.).
For a tutorial about Toasts, read our Bootstrap Toast Tutorial.
ClassDescriptionExample
.toastCreates the toastTry it
.toast-headerCreates the toast headerTry it
.toast-bodyCreates the toast bodyTry it

Activate Via JavaScript

Toasts must be initialized with jQuery: select the specified element and call the toast() method.

Example

<script>
$(document).ready(function(){
  $('.toast').toast('show');
});
</script>

Toast Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-animation="".
NameTypeDefaultDescriptionTry it
animationbooleantrue
Specifies whether to add a CSS fade transition effect when showing and hiding the toast.
  • true - Add a fading effect
  • false - Do not add a fading effect
Try it
autohidebooleantrueSpecifies whether to hide the toast by defaultTry it
delaynumber500Specifies the number of milliseconds it will take to hide the toast once it is shown.Try it

Toast Methods

The following table lists all available toast methods.
MethodDescriptionTry it
.toast(options)Activates the toast with an option. See options above for valid valuesTry it
.toast("show")Shows the toastTry it
.toast("hide")Hides the toastTry it
.toast("dispose")Hides and destroys the toastTry it

Toast Events

The following table lists all available toast events.
EventDescriptionTry it
show.bs.toastOccurs when the toast is about to be shownTry it
shown.bs.toastOccurs when the toast is fully shown (after CSS transitions have completed)Try it
hide.bs.toastOccurs when the toast is about to be hiddenTry it
hidden.bs.toastOccurs when the toast is fully hidden (after CSS transitions have completed)Try it



Credit: www.w3schools.com
Bootstrap JS Toasts Bootstrap JS Toasts Reviewed by webmission on 10:43 Rating: 5

No comments:

Powered by Blogger.