I want to change the ‘title’ color in SweetAlert2. How can I do that? Thank you in advance
function CustomConfirm(title, message, type) { return new Promise((resolve) => { Swal.fire({ title: title, text: message, icon: type, showCancelButton: true, confirmButtonColor: '#d33', cancelButtonColor: '#6e7d88', confirmButtonText: 'Yes', cancelButtonText: "No" }).then((result) => { if (result.isConfirmed) { resolve(true); } else { resolve(false); } }); }); }
Advertisement
Answer
Here is my final function:
Swal.fire({ title: "<h5 style='color:red'>" + title + "</h5>", text: message, icon: type, showCancelButton: true, confirmButtonColor: '#d33', cancelButtonColor: '#6e7d88', confirmButtonText: 'Yes', cancelButtonText: "No" })