question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swal 8.x.x doesn't show correctly (styles are missing)

See original GitHub issue

Current behavior

Hi ! We’re trying to fire a swal in an angular app.
I’ve just downloaded the latest version of sweetalert2 (8.0.1) from npm and imported it in my angular componenent (angular 6 with typescript). Then i tried to fire the swal in ngOnInit() with a code snippet taken from sweetalert2 website, however, the swal doesnt popup, swal’s html elements are rather added to the DOM, without being styled :

image

We are using the standard sweetalert2 library, not ngx-sweetalert2, and it seems to be a problem with version 8 only, because rolling back to version 7.33.1 fix this issue.

Note that, I’ve not tested v8.0.1 without using angular or using ngx-sweetalert2.

Expected behavior

The sweetalert should appear normaly, as it’s demonstrated on sweetalert’s website.

Live demo

Here’s the code of my component :

import { Component, OnInit } from '@angular/core';
import Swal from 'sweetalert2';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  ngOnInit(): void {
    Swal.fire(
      'Good job!',
      'You clicked the button!',
      'success'
    )
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:20 (15 by maintainers)

github_iconTop GitHub Comments

7reactions
limontecommented, Mar 7, 2022

Hello! I am using SweetAlert v11.4.4 with Vite and React on the latest version and the styles are not added to the header. I had to use import as Limote suggests and it worked

import Swal from 'sweetalert2/dist/sweetalert2.all.js';

This would work, but here’s a slightly better solution:

import Swal from 'sweetalert2'
import 'sweetalert2/dist/sweetalert2.css'
2reactions
limontecommented, Jan 27, 2019

Here’s how I solved it for sweetalert2-webpack-demo:

webpack.config.babel.js:

module.exports = {
  ...
  resolve: {
    mainFields: [
      'main',
      'module'
    ]
  },
  ...
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sweet Alert 2 Icon Does Not Render Properly - Stack Overflow
The modal opens as expected but the icon and the animation do not render properly. My code snippets are from the website SweetAlert2....
Read more >
Known Issues - The Events Calendar
Clicking on an event link in a calendar view or widget triggers a 404 page not found error. Important: this issue is addressed...
Read more >
Solving similar triangles (video) - Khan Academy
Cross-multiplying is often used to solve proportions. As an example: 14/20 = x /100. Then multiply the numerator of the first fraction by...
Read more >
Simplex Fire Products - Fault & Assistance Guide
Identifying Simplex® 4100 Series Faults . ... Card Missing/Failed . ... The circuit card is not communicating correctly with the panel ...
Read more >
2.1-2.10 AP-Style MC Practices & Quizzes Flashcards | Quizlet
However, the program segment does not work correctly. ... d)Swap the first two input/assignment blocks (i.e., x ← INPUT, y ← INPUT).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found