I am trying to setup some custom svg icons like this
<i class="my-svg-icon"></i>
I have the svg displayed but cannot adjust the color
.my-svg-icon {
height: 25px;
width: 25px;
color: red !important;
content: url('/mysvg.svg');
}
I have set the stroke in the svg to be currentColor and the fill is none.
3
Answers
CSS
mask
and-webkit-mask
properties are used to display the SVG as a mask image, allowing you to apply the color usingbackground-color: currentColor
.NOTE: Ensure your SVG uses
currentColor
for the stroke or fill.Instead of using the i tag, try using the svg tag. By using the svg tag you can add a color property like this:
Source
You could mention
my-svg-icon svg path
to change color.Use css:
Below I have shared an example. Hope it helps!