Skip to content

Component-State Styling of SVGs #143

Discussion options

You must be logged in to vote

I was able to figure it out pretty quickly after posing this question, using the styled API that you have documented here!

This is the code that ended up working:

const StyledPlus = styled(PlusIcon, {classProps: ["fill"]})

const MyPlusIcon = ({ fill, ...props }) => {
  return (
    <StyledPlus {...props } fill={fill} />
  )
}
<Pressable className='component'>
  <MyPlusIcon size={32} fill='fill-white component-hover:fill-blue-500' />
</Pressable>

Honestly, I'm not sure that I exactly understand how the styled API transforms the properties and what magic happens behind the scenes, but that may just come with time.

Perhaps my only remaining question might be which type I need to declare on …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@marklawlor
Comment options

@justinmcbride
Comment options

Answer selected by justinmcbride
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants