SweetAlert2 Dialogs
Success and confirm-delete dialogs powered by SweetAlert2.
Requires Bootstrap 5, SweetAlert2. 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><script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script><div class="d-flex gap-2"><button class="btn btn-success" id="swOk">Success alert</button><button class="btn btn-danger" id="swDel">Confirm delete</button></div>document.getElementById('swOk').onclick=function(){Swal.fire({icon:'success',title:'Saved!',text:'Your changes were saved.',timer:2000})};
document.getElementById('swDel').onclick=function(){Swal.fire({title:'Delete this?',text:'This cannot be undone.',icon:'warning',showCancelButton:true,confirmButtonColor:'#dc3545',confirmButtonText:'Delete'}).then(function(r){if(r.isConfirmed)Swal.fire('Deleted!','','success')})};Free to use.This component uses Bootstrap 5, SweetAlert2 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.