React-toastify: Problem with styles in next.js

Created on 21 Jan 2020  路  2Comments  路  Source: fkhadra/react-toastify

Hey, I'm using next.js in my project, and I configure all loaders in the right way, but when I try to use the Toastr, it's coming without style.
Some tip about it?

question

Most helpful comment

Below works for me

// pages/_app.js
import { ToastContainer, Slide } from 'react-toastify';

import 'react-toastify/dist/ReactToastify.min.css';
const MyApp = ({ Component, pageProps }) => {
  return (
    <>
      <Component {...pageProps} />
      <ToastContainer
        className="impct-toast"
        position="top-center"
        autoClose={3000}
        hideProgressBar
        newestOnTop
        closeOnClick
        rtl={false}
        pauseOnVisibilityChange
        draggable={false}
        pauseOnHover
        transition={Slide}
      />
    </>
  );  
};

export default MyApp;

All 2 comments

Hello,

Do you import the css file at the root of your application? I had the same issue with nextjs with another library. I had to import the css at the root to solve my issue.

Below works for me

// pages/_app.js
import { ToastContainer, Slide } from 'react-toastify';

import 'react-toastify/dist/ReactToastify.min.css';
const MyApp = ({ Component, pageProps }) => {
  return (
    <>
      <Component {...pageProps} />
      <ToastContainer
        className="impct-toast"
        position="top-center"
        autoClose={3000}
        hideProgressBar
        newestOnTop
        closeOnClick
        rtl={false}
        pauseOnVisibilityChange
        draggable={false}
        pauseOnHover
        transition={Slide}
      />
    </>
  );  
};

export default MyApp;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

giocodes picture giocodes  路  3Comments

fkhadra picture fkhadra  路  4Comments

AllyssonAlas picture AllyssonAlas  路  4Comments

JaLe29 picture JaLe29  路  5Comments

prmichaelsen picture prmichaelsen  路  5Comments