Toasts Bootstrap JS


Griller les classes CSS

Le composant Toast est comme une boîte d'alerte qui ne s'affiche que pendant quelques secondes lorsque quelque chose se produit (c'est-à-dire lorsque l'utilisateur clique sur un bouton, soumet un formulaire, etc.).

Pour un tutoriel sur Toasts, lisez notre tutoriel Bootstrap Toast .

Class Description Example
.toast Creates the toast
.toast-header Creates the toast header
.toast-body Creates the toast body

Activer via JavaScript

Les toasts doivent être initialisés avec jQuery : sélectionnez l'élément spécifié et appelez la toast()méthode.

Exemple

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

Options de pain grillé

Les options peuvent être transmises via des attributs de données ou JavaScript. Pour les attributs de données, ajoutez le nom de l'option à data-, comme dans data-animation="".

Name Type Default Description Try it
animation boolean true

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
autohide boolean true Specifies whether to hide the toast by default
delay number 500 Specifies the number of milliseconds it will take to hide the toast once it is shown.

Méthodes de toast

Le tableau suivant répertorie toutes les méthodes de toast disponibles.

Method Description Try it
.toast(options) Activates the toast with an option. See options above for valid values
.toast("show") Shows the toast
.toast("hide") Hides the toast
.toast("dispose") Hides and destroys the toast

Événements Toasts

Le tableau suivant répertorie tous les événements toast disponibles.

Event Description Try it
show.bs.toast Occurs when the toast is about to be shown
shown.bs.toast Occurs when the toast is fully shown (after CSS transitions have completed)
hide.bs.toast Occurs when the toast is about to be hidden
hidden.bs.toast Occurs when the toast is fully hidden (after CSS transitions have completed)