VOOZH about

URL: https://www.geeksforgeeks.org/bootstrap/bootstrap-5-toasts-methods/

⇱ Bootstrap 5 Toasts Methods - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Bootstrap 5 Toasts Methods

Last Updated : 27 Jul, 2025

Bootstrap 5 Toasts Methods are used to perform some specific tasks on toasts like the show, hide, etc methods. All the methods are mentioned below and described well, for brief clearance about those methods.

Toasts are a type of alert box that is used to show a message or an update to the user. For example, submitting a form, clicking a button, or maybe a push notification inside the website. The alert box type of toast is shown for a couple of seconds. 

Bootstrap 5 Toasts methods:

  • show(): The show() method is used to show the toast when it is triggered.
  • hide(): The hide() method is used to hide the toast from the display.
  • dispose(): The dispose() method is used to hide the toast from the display but it will remain on the DOM but will not show anymore.
  • getInstance(): The getInstance() method is used to allow you to get the scroll spy instance associated with a DOM element.
  • getOrCreateInstance(): The getOrCreateInstance() method is used to allow you to get the scroll spy instance associated with a DOM element, or create a new one if it was not initialized.

Syntax:

toast.toast_method()

Below example illustrate the Bootstrap 5 Toasts Methods:

Example 1: In this example, we will see the effect of the show() method.

Output:

Example 2:  In this example, we will see the effect of the hide() method.

Output:

Reference:https://getbootstrap.com/docs/5.0/components/toasts/#methods

Comment
Article Tags:

Explore