Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change font family of sweetalert

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
        },
like image 657
farshid azizi Avatar asked Jul 17 '19 15:07

farshid azizi


People also ask

How do I change my sweet alert text color?

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.

How do you use SweetAlert?

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.


2 Answers

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.

like image 64
Ouroborus Avatar answered Oct 28 '22 10:10

Ouroborus


Add this to the css!

.swal2-popup {
  font-size: 1.6rem !important;
  font-family: Georgia, serif;
}
like image 29
Arun P Avatar answered Oct 28 '22 10:10

Arun P