Using CSS to change icon color of uploaded icons

I have been using some custom CSS code in themes to get some cool and needed effects for my dashboard. I have been playing around with code to change the color of an icon. The following CSS code works great for system icons:

.–theme-style-active .icon {color: blue};

When I use a icon I created in photoshop (of type png) and uploaded into my sharptools icon library, it doesn’t change the color.

Interestingly, the code:

.–theme-style-active .icon {background-color: blue};

Does change the background of tiles I have uploaded.

Anyone else attempting to do this and have had any success?

That makes sense as a PNG is a ‘raster’ image where the pixels are fixed much like a photo.

You might find the following discussion from another thread helpful:

As you can tell from the above, SVG images tend to be preferred for most cases – especially if you want to be able to ‘recolor’ single color icons.

Josh,

This is FANTASTIC information. I was “today years old” when I learned the difference between SVG and PNG.

Using what you explained, I downloaded a very specific icon that is SVG, uploaded it into sharptools, and when I used it, low and behold, the color changed.

After jumping through some hoops, I was able to convert one of my simpler png icons I created in photoshop, converted it to SVG using a tool online, then modify it with Adobe Illustrator. Took playing with some settings to get it to work but was successful.

I am pretty sure that some of my more complex pngs will not convert properly, because I used shading to create multiple tones of white for my icons. When I convert those, it changes everything to monochrome, so it looses the impact.

Overall was a great learning experience, and for simpler monochrome icons I have created, I can have them in SVG and be able to have sharptools successfully convert the color (when I put white icons on white shade background) properly as it does for the system icons.

Thank you!

1 Like