Ion-toast change background-color problem

Hello! I have created a component and inside it, I am using ion-toast. So I added cssClass to change the background-color of the toast. I have searched every topic regarding it, but nothing works. The docs are not helpful at all. What should I do in order to make it work? Basically I need two different classes based in post result. If I get an error, I want background-color: red and if I get a success, I want the .toast-message to have background-color: green. Any clues? Thank you.

Which version of Ionic are you using? v4 or v3?

I am using Ionic 4.
Post must use 20 characters lol ionic team.

Try this:

cssClass: "toast-mess"

in global.scss

ion-toast.toast-mess {
    opacity: 0.9;
    text-align: center;
    color: var(--ion-color-light);
    --background: var(--ion-color-dark);
}
4 Likes

Hi @smbu that worked!! Thank you very much!

Thanks @smbu! Also worked for me!

tanks @smbu , worked in my app.