1

I would like to change the color of a svg image <img src="someImage.svg" className="icon"> to #ffffff. I tried using color and fill but both didn't work.

Currently I style it with filter. It works but I don't want to use it as it is too vague:

.icon {
filter: invert(100%) sepia(7%) saturate(0%) hue-rotate(158deg)
        brightness(108%) contrast(109%);
}
Celia
  • 59
  • 6
  • I think this was answered before here: https://stackoverflow.com/questions/24933430/img-src-svg-changing-the-styles-with-css – Abrar Siam Feb 23 '22 at 09:33
  • Are you able to put the SVG into your code? You can’t change fill etc of an svg brought in from a file as you have discovered. – A Haworth Feb 23 '22 at 09:40
  • Is this CSS-in-SVG, or CSS-in-HTML? Also, `` is not the correct attribute - it should be `` - unless this is JSX for React? – Dai Feb 23 '22 at 09:40
  • I'm using react – Celia Feb 23 '22 at 09:46

0 Answers0