Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Creating Bootstrap Toast with Different Color Schemes</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script> <script> document.addEventListener("DOMContentLoaded", function(){ var toastElementList = [].slice.call(document.querySelectorAll(".toast")); var toastList = toastElementList.map(function(element){ return new bootstrap.Toast(element, { autohide: false }); }); }); </script> </head> <body> <div class="m-4"> <p><strong>Note:</strong> The <code>.show</code> is added to display the toast, and the class <code>.fade</code> apply a CSS fade transition to the toast. By default, toast it is hidden.</p> <div class="toast-container"> <!--Blue variant --> <div class="toast bg-primary text-white fade show"> <div class="toast-header bg-primary text-white"> <strong class="me-auto"><i class="bi-gift-fill"></i> We miss you!</strong> <small>10 mins ago</small> <button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast"></button> </div> <div class="toast-body"> It's been a long time since you visited us. We've something special for you. <a href="#" class="text-white">Click here!</a> </div> </div> <!--Red variant --> <div class="toast bg-danger text-white fade show"> <div class="toast-header bg-danger text-white"> <strong class="me-auto"><i class="bi-gift-fill"></i> We miss you!</strong> <small>10 mins ago</small> <button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast"></button> </div> <div class="toast-body"> It's been a long time since you visited us. We've something special for you. <a href="#" class="text-white">Click here!</a> </div> </div> <!--Yellow variant --> <div class="toast bg-warning text-dark fade show"> <div class="toast-header bg-warning text-dark"> <strong class="me-auto"><i class="bi-gift-fill"></i> We miss you!</strong> <small>10 mins ago</small> <button type="button" class="btn-close" data-bs-dismiss="toast"></button> </div> <div class="toast-body"> It's been a long time since you visited us. We've something special for you. <a href="#" class="text-dark">Click here!</a> </div> </div> <!--Green variant --> <div class="toast bg-success text-white fade show"> <div class="toast-header bg-success text-white"> <strong class="me-auto"><i class="bi-gift-fill"></i> We miss you!</strong> <small>10 mins ago</small> <button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast"></button> </div> <div class="toast-body"> It's been a long time since you visited us. We've something special for you. <a href="#" class="text-white">Click here!</a> </div> </div> <!--Light blue variant --> <div class="toast bg-info text-dark fade show"> <div class="toast-header bg-info text-dark"> <strong class="me-auto"><i class="bi-gift-fill"></i> We miss you!</strong> <small>10 mins ago</small> <button type="button" class="btn-close" data-bs-dismiss="toast"></button> </div> <div class="toast-body"> It's been a long time since you visited us. We've something special for you. <a href="#" class="text-dark">Click here!</a> </div> </div> </div> </div> </body> </html>