Uzair Khan
Uzair Khan

Reputation: 2970

Use background image using css file in ReactJs

I have a react application in which on checking certain checkboxes I am adding or changing a certain image icon.

.checkbox1:checked ~ .icon-span {
   background: url('../../../../assets/images/icon_plus.svg');
}

Which is giving me this:

background: url([object Module]); //invalid property value

But path is correct, how do I correct this?

Upvotes: 1

Views: 303

Answers (1)

Ameya Shetye
Ameya Shetye

Reputation: 46

This should work .checkbox1:checked ~ .icon-span { background: url(${require("../../../../assets/images/icon_plus.svg")}); }

Upvotes: 1

Related Questions