t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.4k stars 2.84k forks source link

button className is not working #816

Open adrianmak opened 6 years ago

adrianmak commented 6 years ago

I tried to add bootstrap button class on the button. But it didn't work Checked the html output source, my custom class names are not added

 swal({
                text: "Form has not completed. Submission failed",
                icon: "warning",
                button: {
                    confirm: {
                        text: "OK",
                        className: "btn btn-primary",
                    },
                }
            });
hannahmay commented 6 years ago

Hi, I am also having the same issue.

swal({ title: 'Recover Item', text: 'Would you like to recover the selected items?', buttons: { confirm: { text: "Yes", value: true, visible: true, className: "bg-warning", closeModal: true, }, cancel: { text: "Cancel", value: true, visible: true, className: "bg-default", closeModal: true, } } }, function () { ... });

vlcheong commented 6 years ago

className failed to take more than one classes. Failed to execute 'add' on 'DOMTokenList': The token provided ('btn btn-success') contains HTML space characters

Nemachtilli commented 1 year ago

`const swalWithBootstrapButtons = Swal.mixin({ customClass: { confirmButton: 'btn btn-success', cancelButton: 'btn btn-danger' }, buttonsStyling: false })

swalWithBootstrapButtons.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", icon: 'warning', showCancelButton: true, confirmButtonText: 'Yes, delete it!', cancelButtonText: 'No, cancel!', reverseButtons: true }).then((result) => { if (result.isConfirmed) { swalWithBootstrapButtons.fire( 'Deleted!', 'Your file has been deleted.', 'success' ) } else if ( / Read more about handling dismissals below / result.dismiss === Swal.DismissReason.cancel ) { swalWithBootstrapButtons.fire( 'Cancelled', 'Your imaginary file is safe :)', 'error' ) } })`

Add class in customClass