vite-plugin-svg-icons icon indicating copy to clipboard operation
vite-plugin-svg-icons copied to clipboard

Color of svg changed.

Open hellomrbigshot opened this issue 3 years ago • 7 comments

I have a svg file called menu-more.svg

<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="50" height="50" fill="#353A58"/>
<path d="M17 18H33" stroke="#F2F4FA" stroke-width="2" stroke-linecap="round"/>
<path d="M17 25H33" stroke="#F2F4FA" stroke-width="2" stroke-linecap="round"/>
<path d="M17 32H33" stroke="#F2F4FA" stroke-width="2" stroke-linecap="round"/>
</svg>

It used to be like this menu-more-light

But when i import this with the plugin, it shows like this menu-more-dark

Color of path changed. How it happens.

hellomrbigshot avatar Feb 08 '22 10:02 hellomrbigshot

Lastest version stroke is replaced. image The new version is not compatible.

baiye0 avatar Feb 09 '22 10:02 baiye0

Lastest version stroke is replaced. image The new version is not compatible.

I have the same problem.How to change the color

ZuulAndRibbon avatar Mar 07 '22 04:03 ZuulAndRibbon

While this behavior should probably be opt-in, it's actually quite useful (at least for all my use cases). The currentColor keyword represents the element's color CSS property.

In other words: in order to change the icon color, change the color property of the icon element or any parent element.

michaelhue avatar Mar 31 '22 09:03 michaelhue

I agree this should be an opt-in - at present there is no way to leave the SVG stroke colour untouched. Our use case is that we have multiple colours and we define currentColor in the source SVG where we want to make use of CSS overrides.

peterdzl avatar Jul 15 '22 18:07 peterdzl

I added a pull request to make this behaviour optional

https://github.com/vbenjs/vite-plugin-svg-icons/pull/68

digitalacorn avatar Jul 15 '22 20:07 digitalacorn

Thank you @digitalacorn. I would like to opt-in to this stroke replacing as well. Can we get this merged soon? @anncwb

nelsonjd avatar Aug 09 '22 19:08 nelsonjd

There are other libraries as well. https://github.com/Jevon617/unplugin-svg-component https://github.com/Jevon617/unplugin-svg-component?tab=readme-ov-file#plugin-configuration preserveColor option

inhyuck avatar Jan 30 '24 06:01 inhyuck