Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change SVG Fill color in React JS

Tags:

html

reactjs

svg

Consider:

import LOGO from './something.svg';
<img src={LOGO} className={'logo'} alt="Logo"/> // 

How can I change fill color of SVG in ReactJS ?

I've tried also to use ReactComponent but I got 'ReactComponent' is not exported from ....

import { ReactComponent as Logo1 } from './something.svg';
<Logo1 /> // doesn't work : 'ReactComponent' is not exported from ....
like image 493
JAN Avatar asked Oct 13 '25 09:10

JAN


1 Answers

In your jsx:

import { ReactComponent as Logo } from './something.svg';

const MyComponent = () => <Logo className="logo" />

in your css:

.logo > path {
   fill: "white"
}

This should work just fine

like image 89
Akin Aguda Avatar answered Oct 14 '25 22:10

Akin Aguda