question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding a class doesn't override backgroundColor

See original GitHub issue

If I do NOT set a backgroundColor option when calling Toastify, but add a className that maps for instance to a Bootstrap alert class, the Toast’s default backgroundColor still takes precedence over the class’ background color.

i.e.

 Toastify({
    text: "A simple warning alert—check it out!",
    duration: 3000,
    close: true,
    gravity: "bottom",
    positionLeft: false,
    className:"alert alert-warning>"
    }).showToast();

Should yield the following:

image

Instead I get:

image

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
CharlieIGGcommented, Sep 10, 2019

FYI I ended up doing the following to achieve what I wanted (thankfully I was already packing SCSS):

@each $color,
$value in $theme-colors {

  .toastify.alert-#{$color},
  .alert-#{$color} {
    @include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), color-yiq(theme-color-level($color, $alert-bg-level)));

    .close,
    .alert-link {
      color: color-yiq(theme-color-level($color, $alert-bg-level));
    }
  }
}
1reaction
patrickliu-hkcommented, Oct 7, 2021

I added one-line CSS to solve that

.toastify {
  background-image: unset;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing class to element doesn't change background color
It's the order of your CSS. You add .colorBrightRed and .colorRedNoHov to the element when it flashes, and for the red colors, ....
Read more >
Change Background Color Using JavaScript
Learn how to change the background color of an HTML Element dynamically in JavaScript in THREE different ways.
Read more >
background-color - CSS: Cascading Style Sheets | MDN
The background-color CSS property sets the background color of an element.
Read more >
HTML Background Color Tutorial – How to Change a Div ...
Let's change the background color of the divs by adding styles to the classes. You can follow along by trying the examples in...
Read more >
How to Change Text and Background Color in CSS
You might be wondering what happens if you don't set the color property in your CSS. That's a good question. The default text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found