Bootstrap – Toasts


Bootstrap – Toasts


”;


This chapter discusses about the component toasts. Toasts are like alert messages, that are lightweight and customizable. Toasts are a useful tool for providing responsive and unobtrusive notifications to the user.

  • Toasts in Bootstrap are used to display non-blocking notifications at the bottom or top of the screen.

  • They can provide feedback or alert the user to certain events or actions, without interrupting their current task.

  • Toasts can contain text, images, or any other HTML content, and can be customized to fit the design of the website or application.

  • They can also be dismissed by the user or have a set duration before disappearing on their own.

  • You must initialize the toasts yourself, as they are opt-in for performance reasons.

  • If you do not specify autohide: false, toasts will automatically hide.

  • The animation effect of the toast component is dependent on the prefers-reduced-motion media query.

  • A header and a body is recommended to be added to a toast to make it more extensible and predictable.

  • You require a single element to contain your toast and must have a dismiss button.


Basic toast

In order to create a basic toast, you need to use the .toast class and add a .toast-header to provide a heading and a .toast-body to add the content.

Let us see an example of a basic toast: