</> ConvertAtlas Developer Tools
Bootstrap 5 · Intermediate

Toast Trigger Buttons

Buttons that fire colored Bootstrap toasts via the Toast API.

Requires Bootstrap 5. Add the CDN tags below to your page (styles in <head>, scripts before </body>). The downloaded file already includes them.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<div><div class="d-flex gap-2"><button class="btn btn-success btn-sm" onclick="tg('success','Saved!')">Success</button><button class="btn btn-danger btn-sm" onclick="tg('danger','Failed!')">Error</button></div><div class="toast-container position-fixed bottom-0 end-0 p-3" id="tgWrap"></div></div>
function tg(type,msg){var el=document.createElement("div");el.className="toast align-items-center text-bg-"+type+" border-0";el.innerHTML='<div class="d-flex"><div class="toast-body">'+msg+'</div><button class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button></div>';document.getElementById("tgWrap").appendChild(el);var t=new bootstrap.Toast(el,{delay:2500});t.show();el.addEventListener("hidden.bs.toast",function(){el.remove()})}
Free to use.This component uses Bootstrap 5 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.