Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svg Path stroke color should not fixed to '#000' instead of 'currentColor' #171

Open
zhangriyueming opened this issue Apr 30, 2020 · 7 comments

Comments

@zhangriyueming
Copy link

Svg Path stroke color should not fixed to '#000' instead of 'currentColor'

@ShimiSun
Copy link
Member

ShimiSun commented May 1, 2020

Can you please explain what do you mean by currentColor and how you are trying to use it?

@DavidJFelix
Copy link

DavidJFelix commented May 18, 2020

@ShimiSun I found this issue wanting the same thing. I'm trying to use the icons with react-icons and I was unable to change the color of grommet icons in the same way that I'm able to with others like font-awesome and feather. The currentColor ask is that rather than define the stroke as #000, it be set to the SVG label currentColor. This means that by default in HTML, it will be black, but if a user sets a font color in a parent HTML element, the SVG will use that color for the stroke color. This allows people to easily style the icons for whatever they're doing.

It doesn't seem like react-icons has a way to pass parameters to grommet icons outside of css styling.

@ShimiSun ShimiSun removed the waiting label May 18, 2020
@aravindanve
Copy link

aravindanve commented May 23, 2020

@zhangriyueming @DavidJFelix you are right. If you are looking for a temporary solution, overriding the stroke using css worked for me. But the caveat is you will have to add the class my-grommet-icon to your icon component:

.my-grommet-icon path {
  stroke: currentColor;
}

Or if you are using styled-system, theme-ui or rebass, you could do this:

const GrIconWrapper = ({ icon: Icon, sx, ...props }) => (
  <Box
    {...props}
    as={Icon}
    sx={{
      ...sx,
      path: {
        stroke: 'currentColor',
      },
    }}
  />
);

// and use it like
<GrIconWrapper icon={GrForwardTen} />

@TomasB
Copy link

TomasB commented Mar 12, 2021

@ShimiSun It's a simple search and replace across all files. Do you need help with this? Should take only minutes to fix to make them usable.

@ShimiSun
Copy link
Member

@ShimiSun It's a simple search and replace across all files. Do you need help with this? Should take only minutes to fix to make them usable.

Go for it buddy, thanks!

@TomasB
Copy link

TomasB commented Mar 12, 2021

@ericsoderberghp @alansouzati It seems that having non "#" starting color value breaks StyledIcon ?

@ShimiSun
Copy link
Member

@TomasB Not sure what you are asking, would you like to file a contribution with the suggested fix you have in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants