0

Trying to change background color of Toast container, the code below suppose to make this. I dont know what I am missing but it doesnt work...

this is what I tried:

.toastError {
  margin-top: 15rem;// this works
  &.Toastify__toast--error {
    background: #bd362f !important;// this is is not...
  }
}

react component:

import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
..
return (
<ToastContainer position="top-center"
          className={styles.toastError}
          autoClose={4000}
          hideProgressBar={false}
          newestOnTop={false}
          closeOnClick
          rtl={false}
          pauseOnFocusLoss
          draggable
          pauseOnHover
        />

margin-top effect the component but cant change the color, the element looks like below in browser : enter image description here

What do I need to do make it work?

2
  • You forgot the space here between the ampersand and the class &.Toastify__toast--error Commented Apr 21, 2021 at 13:56
  • @Martin thanks but doesnt work Commented Apr 21, 2021 at 14:15

1 Answer 1

5

You use cssLoader with css modules, right? maybe you must mark .Toastify__toast--error as global. Scoping classnames in cssLoader

.toastError {
  margin-top: 15rem;

  :global(.Toastify__toast--error) {
    background: #bd362f !important;
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.