Skip to content
Advertisement

Using SweetAlerts 2 themes

We’re looking to use the themes, but we can’t figure out how to do so – we’re not very experienced developers. We understand that we need to import the corresponding CSS file for the desired theme, but how do you then apply it? My goal is to have a dropdown with the different themes and show the modal with the selected theme.

The easiest would be to have a “theme” parameter in the options as the other settings, but there are none. We’d really appreciate your help!

Advertisement

Answer

Solved it by appending the CSS to the page header.

if (properties.theme === "Default") {$('head').append('<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-default@5.0.11/default.min.css">')}
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement