Search code examples
sweetalert2

Adding a class to sweet alert 2


This question has been raised for sweetalert 1 Adding class to sweet alert

Now my question is, how can i add a custom class in sweetalert2?

className: "new_class" does not work for me.


Solution

  • For sweetalert2 the custom class can be added to multiple targets:

    Swal.fire({
      ...
      customClass: {
        container: '...',
        popup: '...',
        title: '...',
        closeButton: '...',
        icon: '...',
        image: '...',
        htmlContainer: '...'
        input: '...',
        inputLabel: '...',
        validationMessage: '...',
        actions: '...',
        confirmButton: '...',
        denyButton: '...',
        cancelButton: '...',
        loader: '...',
        footer: '...'
        timerProgressBar: '...'
      }
    })
    

    Docs: https://sweetalert2.github.io/#custom-class