vite-plugin-svgr icon indicating copy to clipboard operation
vite-plugin-svgr copied to clipboard

如何改变颜色

Open Over-reaction opened this issue 1 year ago • 1 comments

使用这个 我如何改变svg的颜色

Over-reaction avatar Aug 03 '23 09:08 Over-reaction

参考 https://github.com/pd4d10/vite-plugin-svgr/issues/72#issue-1609038919 的方式引入 SVG 组件后,可通过 <SvgIcon fill="currentColor" />,以及为 <svg> 后代元素 <path> 设置 fill: inherit; 来改变颜色

<span style={{ color: "blue" }}>
  <SvgIcon
      className="change-color"
      fill="currentColor"
   />
</span>
.change-color path{
  fill: inherit;
}

JackpotM1103 avatar Sep 06 '23 06:09 JackpotM1103