v-toaster icon indicating copy to clipboard operation
v-toaster copied to clipboard

Hard to customize background color

Open Milad opened this issue 7 years ago • 6 comments
trafficstars

Hello

I like this component because it's straight forward and easy to use. But the default colors don't match my theme.

I'm using this with Bulma, and I'd like to use Bulma's colors. So in my vue mixin I have:

    methods: {
        toasterError(errMessage) {
            this.$toaster.add(errMessage, {
                theme: 'notification is-danger',
                timeout: 2500
            });
        }
    }

Unfortunately, this color doesn't show because the css has default color in .v-toaster .v-toast. Is it possible to remove that default background color?

Regards

Milad avatar Jan 27 '18 20:01 Milad

it's just you override the css, example:

.v-toaster .v-toast {
  background: <your defalt color>;
  border-color: <your defalt border color>;
}
.v-toaster .v-toast.v-toast-error {
  background: <your error color>;
  border-color: <your error border color>;
}

paliari avatar Jan 27 '18 21:01 paliari

It's a dependency that I shouldn't change myself. And since I want to use colors from another framework, then the best option is to pass classes.

Milad avatar Jan 28 '18 02:01 Milad

So it's simpler, it's just you use the method:

this.$toaster.add(this.message, {theme: 'your custom class'});

paliari avatar Jan 28 '18 10:01 paliari

Thanks Paliari, this is exactly what I did.

        errorMsg(message) {
            this.$toaster.add(message, {
                theme: 'notification is-danger',
                2500
            });
        }

Check here the result.

The classes are: v-toast notification is-info v-toast-enter-to. The background-color in v-toast class is taking higher priority than the bg-color in is-info.

Now I could use !important to enforce the color of is-info but even this is coming from a 3rd-party dependency that I shouldn't change.

I believe the best option is to remove the bg-color from v-toast. Please correct me if I'm wrong.

Milad avatar Jan 28 '18 13:01 Milad

This has been resolved by importing v-toaster css file before Bulam's.

import 'v-toaster/dist/v-toaster.css';
import 'bulma/bulma.sass';

Not the ideal solution, but this useful library is a little bit opinionated.

Milad avatar Feb 08 '18 17:02 Milad

Reach for unbiased purity 🪷

Omni-Engineering avatar Jan 29 '23 16:01 Omni-Engineering