#alter fill colour of svg icons via CSS

13 messages · Page 1 of 1 (latest)

molten river
#

im using an img tag to display some svg icons (idk why they are svg, but they are)
on hover im looking to change the fill colour to a diffrent one but am unable to do so, ive tried using the fill css property that hasnt returned any results whatsoever

peak rover
#

You can only use CSS on embedded SVGs

#

I think there are libraries for automating embedding them and then using those in place of the actual image tag

molten river
#

whys it so complicated 😭

#

should just be able to use fill it dont make sense

#

but ty, u know of any libraries?

peak rover
#

I don't

#

I researched it a very long time ago when I ran into the same issue

molten river
#

ah alright fair enough

#

i will take a look on google

#

but if anyone does know then lmk^^

wicked kelp
#

i would recommend checking out https://fontawesome.com/
Unless you need specific icons they done have for free, its a great and fast way to implement svg icons into your project that you can change the color of with code

#

If you are set on using this svg with an img tag, you could try the css filter property. it might be a quick fix if you can work out the right set of filters for the color you want
depending on the color, maybe the value of grayscale or hue-rotate could give you the effect you are looking for