system-props / system-props

Responsive, theme-based style props for building design systems with React. Written in TypeScript.

Home Page:https://system-props.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SVG stroke and fill props values on DOM node

jmakGH opened this issue · comments

Looks like the stroke and fill props that get threaded through to the underlying DOM node don't receive the transformed values.

Screen Shot 2021-04-19 at 8 20 34 AM

I think this is expected. The transform happens within the styled-component, rendered by the component that receives the fill and stroke props. I think ideally those attributes would not get passed down to the underlying element, and let the styling be applied by CSS.

You can use shouldForwardProp exported from this package alongside styled-components' or Emotion's APIs for configuring the should forward prop behavior. You can see it used in the example:

export const Box = styled('div').withConfig({
shouldForwardProp: (prop, defaultValidtorFn) =>
shouldForwardProp(prop) && defaultValidtorFn(prop),
})<BoxProps>({ boxSizing: 'border-box' }, system(config), ({ sx, ...props }) =>
css(sx)(props)
);