P
P
pabadm2020-07-14 03:42:45
css
pabadm, 2020-07-14 03:42:45

How to apply styles to an icon if it is rendered via the object tag (using React)?

I want to change the icon's fill to red. Accordingly, I gave the object a class that says fill: red;.
But it turned out that in order to apply at least some styles, you need to add the path to the css file to the icon at the beginning of the document. Where this file should be located, whether it needs to be processed somehow by webpack is not clear.
And most importantly, you need to write classes in that file. And here's the problem - how now to apply that class to the icon through the object tag ?
There is nothing on the Internet about this. Everywhere it is written that you can use the object tag , and in the examples they use inline everywhere.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arseny, 2020-07-14
@pabadm

Mmm... Most likely it will be easier for you if the image is embedded in the document (HTML) or in assets, where you will access using use and get the sprite. If everything is done correctly, then the minimum amount of hemorrhoids and you can safely build in as many times as you like and as you like.
You can look at a rough compact example . Of course, there is no embedding from an external file in it, but understanding that you google google.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question