fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.78k stars 700 forks source link

Overriding CSS for single toast() #1184

Open jukkahuuskonen opened 1 day ago

jukkahuuskonen commented 1 day ago

Feature-request (or info on how to implement if already available) At the moment I am using notistack for my toasts (snackBars), but since it has been pretty much not maintained for nearly 2 years I am planning to migrate to react-toastify Our app has some toasts with custom react-components, mostly error messages. In these cases we don't want any extra padding around our component. With other components that padding is just fine. Is there there a way to override the CSS for a single toast? We would want to override following 2 parts:

.Toastify__toast {
...
padding: 8px; -> padding: 0px
...
}

.Toastify__toast-body {
...
padding: 8px; -> padding: 0px

...
}

What is the current behavior? The two upper toasts are just fine, but with the bottom one we don't want the padding at all: image

The bottom one should look like this: image

If I just override the CSS for the (using emotion) it would also change those first 2 toasts and I don't want that.

Is there any easy way to do this toast-by-toast? Or maybe have the library to just show the custom component without those extra divs around it?

jukkahuuskonen commented 1 day ago

Can the white background be changed separately for each type: info/success/warning/error because that would probably be fine too? As far as I saw, it looked like there is only one background color variable.

jukkahuuskonen commented 3 hours ago

Ok, I found the colored-theme that gives an acceptable solution to this.