The toast component is basically an alert box that is only visible for a couple of seconds when something happens (i.e. when the user clicks on a button, submits a form, etc.).
Use the .toast class and include a .toast-header and .toast-body to generate a toast:
Toast Header
Some text inside the toast body
Note: To start a toast, pick the desired element and use the toast() method. This requires the initialization of jQuery.
All of the “toasts” in the page will be displayed by the code below:
Toasts are by default not visible. To make it visible by default, use the data-autohide=”false” attribute. Use a <button> element and add data-dismiss=”toast” to close it:
Toast Header
5 mins ago
Some text inside the toast body
Take note of the ml-2, mb-1, and mr-auto classes. They are applied to provide designated margins. More about them is covered in the chapter on Bootstrap 4 Utilities.
CodingAsk.com is designed for learning and practice. Examples may be made simpler to aid understanding. Tutorials, references, and examples are regularly checked for mistakes, but we cannot guarantee complete accuracy. By using CodingAsk.com, you agree to our terms of use, cookie, and privacy policy.
Copyright 2010-2024 by Refsnes Data. All Rights Reserved.