DEV Community

Cover image for Fix: SVG Colors not working properly
Visakh Vijayan
Visakh Vijayan

Posted on • Edited on

1 1

Fix: SVG Colors not working properly

We were trying to change the color of an svg. But our initial images were not of the same color. After a while we figured out the best way would be to force them to an initial color and then do filtering.

Here is how our plain svgs looked
Plain SVGs

Here is our code

<img 
src={item.icon} 
style=
{{ 
    height: "100%", 
    width: "auto", 
    borderRadius: "10px", 
    display: "block", 
    filter: "brightness(0) saturate(100%) invert(31%) sepia(82%) saturate(6098%) hue-rotate(256deg) brightness(93%)" 

}} />
Enter fullscreen mode Exit fullscreen mode

The brightness(0) and saturate(100%) turn the image to black.

Top comments (0)

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay