Copy with Toast
A copy button that triggers a real Bootstrap toast on success.
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 style="max-width:360px"><button class="btn btn-primary" id="ctBtn">Copy code</button><div class="toast-container position-fixed top-0 end-0 p-3" id="ctWrap"></div></div>document.getElementById("ctBtn").onclick=function(){navigator.clipboard&&navigator.clipboard.writeText("HELLO-2026");var el=document.createElement("div");el.className="toast align-items-center text-bg-success border-0";el.innerHTML='<div class="d-flex"><div class="toast-body">Copied to clipboard!</div><button class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button></div>';document.getElementById("ctWrap").appendChild(el);var t=new bootstrap.Toast(el,{delay:2000});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.