How can I change the font family in sweetalert? Thank You
swal({
title: "Are you sure?",
text: "Your will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
You can use customClass or showClass to get the CSS class for the popup and change the colors in a CSS file from there. For example: function CustomConfirm(title, message, type) { return new Promise((resolve) => { Swal.
SweetAlert is a method to customize alerts in your applications, websites and games. It allows the user to change it with a standard JavaScript button. You can add a new button to it, change the background color of the button, change the button's text, and add additional alerts that depend on the user's click.
Configuration options are listed here. They do not appear to include an option for changing the font.
However, all of the elements involved in the SweetAlert popup have SweetAlert-specific classes so you should be able to set the fonts via CSS. Some key classes and examples are listed in the SweetAlert docs under Theming.
Add this to the css!
.swal2-popup {
font-size: 1.6rem !important;
font-family: Georgia, serif;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With