简体   繁体   English

react-icons - 无法更改颜色垫圈图标

[英]react-icons - Can't change color Grommet icons

I'm using react-icons and with Font Awesome icons I managed to change color easily with 2 approaches:我正在使用 react-icons 和 Font Awesome 图标,我设法通过 2 种方法轻松更改颜色:

Works with color prop:与颜色道具一起使用:

<FaUserTimes /* color="#023373" */ className="icone icone-40" />

Works with css:与 css 一起使用:

.icone {
  color: #023373; 
}

Now, using Grommet icons nothing seems to work, icons are always black现在,使用 Grommet 图标似乎没有任何效果,图标总是黑色的

<GrFormAdd color="#023373" className="icones" />

.icones {
    font-size: 30px; **Font size works!?**
    color: #023373;
}

在此处输入图像描述

Full Code : https://codesandbox.io/s/pensive-rgb-r8g1t?file=/src/App.js完整代码: https : //codesandbox.io/s/pensive-rgb-r8g1t?file=/ src/ App.js

For color pass a props (i called it blue) like this.对于颜色传递,像这样的道具(我称之为蓝色)。

<Apple color="blue" size="xlarge" />

So on the other end style your icon like this.所以在另一端设计你的图标像这样。

const customColorTheme = deepMerge(base, {
    icon: {
      extend: css`
        ${(props) =>
          props.color === "blue" &&
          `
        fill: #023373;
      `}
      `
    }
  });

I also search for this problem (since I was using only react-icons<\/em> , and not grommet-icons<\/em> & cie)我也在搜索这个问题(因为我只使用react-icons<\/em> ,而不是grommet-icons<\/em> & cie )

Found out you can style your Grommet Icon with simple css :发现您可以使用简单的 css 设置您的 Grommet Icon 样式:

svg path {
    stroke: #023373;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM