10

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
        },
farshid azizi
  • 364
  • 1
  • 5
  • 18

4 Answers4

14

Add this to the css!

.swal2-popup {
  font-size: 1.6rem !important;
  font-family: Georgia, serif;
}
Ouroborus
  • 16,237
  • 4
  • 39
  • 62
Arun P
  • 541
  • 4
  • 11
9

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.

Ouroborus
  • 16,237
  • 4
  • 39
  • 62
1

For sweetalret2 Add this code to you css file First one is for main title and the other for subtitle

      h2#swal2-title
      {
         font-size: 24px;
         font-family:'Lexend';
         color:theme('colors.metal');
      }
      div#swal2-html-container{
         font-size: 16px;
         font-family:'Heebo';
         color: theme('colors.metal');
      }
0

you could actually do it by targeting .swal2-title, so in css

.swal2-title {
  font-family:'Montserrat', sans-serif;
}
Tyler2P
  • 2,324
  • 26
  • 22
  • 31