Bootstrap 5 Toasts Custom content Last Updated : 29 Jul, 2024 Comments Improve Suggest changes Like Article Like Report Bootstrap 5 Toasts Custom content is used to add your own markup by removing sub-components. Users can easily Customize toasts by adding their own content or by adding other bootstrap components inside toast. There are no predefined classes for toast custom content. You can custom-create them by giving additional controls and adding components like cards, icons, etc inside the toast.Pre-requisite: Bootstrap 5 Toast knowledge required.Bootstrap 5 Toasts Custom content Class: There is no predefined class to create custom content on the toast, we can use any Bootstrap 5 utilities, flex-box utilities, or Bootstrap 5 Icons.Syntax:<div class="toast" role="alert"> <div class="toast-header"> Toast Header </div> <div class="toast-body"> <!-- Custom Content for toast body--> </div></div>Example 1: In this example, we customize the toast content by adding two bootstrap buttons inside it. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> <script src= "https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"> </script> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"> </script> </head> <body> <div class="container"> <div> <h1 class="text-success">GeeksforGeeks</h1> <h3> Bootstrap 5 Toasts Custom content</h3> </div> <div> <button type="button" class="btn btn-success" id="toastBtn" onclick="showToast()"> Show the Toast </button> <div id="gfg" class="toast mt-5" role="alert"> <div class="toast-header"> GeeksforGeeks. </div> <div class="toast-body"> <p class="border-bottom mb-3 pb-2"> Accept Privacy Policy? </p> <button type="button" class="btn btn-success btn-sm"> Yes </button> <button type="button" class="btn btn-danger btn-sm" data-bs-dismiss="toast"> No </button> </div> </div> </div> </div> <script> // Initialize the Toasts let myToast = new bootstrap.Toast(document.getElementById('gfg')); function showToast() { myToast.show(); } </script> </body> </html> Output: Example 2: In this example, we added a card inside the toast component. The card has some text and a button inside it. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> <script src= "https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"> </script> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"> </script> </head> <body> <div class="container"> <div> <h2 class="text-success">GeeksforGeeks</h2> <h4> Bootstrap 5 Toasts Custom content</h4> </div> <div> <button type="button" class="btn btn-success" id="toastBtn" onclick="showToast()"> Show the Toast </button> <div id="gfg" class="toast mt-5" role="alert"> <div class="toast-header"> GeeksforGeeks. </div> <div class="toast-body"> <div class="card"> <div class="card-body"> <h6 class="card-title">New Message!</h6> <p class="card-text"><span class="user"> GeeksforGeeks </span> sent you a message.</p> <button class="btn btn-warning btn-sm"> Open Message </button> </div> </div> </div> </div> </div> </div> <script> // Initialize the Toasts let myToast = new bootstrap.Toast(document.getElementById('gfg')); function showToast() { myToast.show(); } </script> </body> </html> Output: Reference: https://getbootstrap.com/docs/5.0/components/toasts/#custom-content Comment More infoAdvertise with us Next Article Bootstrap 5 Toasts Color Schemes P prashantrathore1159 Follow Improve Article Tags : Technical Scripter Web Technologies Bootstrap Technical Scripter 2022 Bootstrap-5 +1 More Similar Reads Bootstrap 5 Toasts Bootstrap 5 Toasts are notifications or messages which the users receive whenever they perform certain actions. They can easily be customized. Overview: Toasts need to be initialized. Apply autohide: false so that the toasts don't automatically hide.Placement: You can place toasts as you want. The t 3 min read Bootstrap 5 Toasts Basic Bootstrap 5 Toasts Basic feature showcases brief alert notifications, resembling mobile and desktop push notifications. It elaborates on fundamental toast functionality, providing a user-friendly way to display important information to users.Bootstrap 5 Toasts Basic Class: No special classes are use 2 min read Bootstrap 5 Toasts Live Bootstrap 5 Toasts Live is used to show the alert notifications. Toasts are brief alerts designed to resemble the push notifications made popular by mobile and desktop operating systems. The Toasts Live feature is used to show a toast in the lower corners of the web page.Toasts Live Classes: No spec 2 min read Bootstrap 5 Toasts Translucent Bootstrap 5 provides the Toasts which are used to show the alert notifications. Toasts are brief alerts designed to resemble the push notifications made popular by mobile and desktop operating systems. The Toast translucent feature is used to be slightly translucent to blend in with the content belo 2 min read Bootstrap 5 Toasts Stacking Bootstrap 5 Toasts Stacking feature is used to wrap multiple toasts in a toast container which will increase the vertical spacing. Toasts Stacking Classes: No special classes are used in Toasts Stacking, you just need to have knowledge of Bootstrap 5 Toasts. Syntax: <div class="toast-container" 2 min read Bootstrap 5 Toasts Custom content Bootstrap 5 Toasts Custom content is used to add your own markup by removing sub-components. Users can easily Customize toasts by adding their own content or by adding other bootstrap components inside toast. There are no predefined classes for toast custom content. You can custom-create them by giv 2 min read Bootstrap 5 Toasts Color Schemes Toasts are a type of alert box that is used to show a message or an update to the user. You can use bootstrap 5 color and background utilities to create different color schemes and customize your toasts. Bootstrap 5 Toasts Color Schemes Classes: We can use the Bootstrap 5 Color classes to color the 2 min read Bootstrap 5 Toasts Placement Bootstrap 5 Toasts which are used to show the alert notifications. Toasts are brief alerts designed to resemble the push notifications made popular by mobile and desktop operating systems. The Toast Placement feature is used to set the position of the toast on the web page. Bootstrap 5 Toasts Placem 4 min read Bootstrap 5 Toasts Accessibility Toasts are the basic push notifications sent to the user its similar to the alert box. To create a basic toast we have to use the class name "toast" inside the toast class we can also add the class "toast-header" and add the header for the toast body, the "toast-body" class can be used. We can also 2 min read Bootstrap 5 Toasts SASS Bootstrap 5 Toasts SASS has a set of variables with default values that can be changed to customize the toasts. Default values of SASS variables of Toasts: $toast-max-width: 350px; $toast-padding-x: 0.75rem; $toast-padding-y: 0.5rem; $toast-font-size: 0.875rem; $toast-color: null; $toast-background- 3 min read Like