Component-State Styling of SVGs #143
-
Hi there, I was wondering how I could combine the Component State styling (specifically looking for This might show the code that I was trying, using react-native-heroicons): <Pressable className='component'>
<PlusIcon size={32} className='component-hover:fill-red-500' />
</Pressable> Referencing the SVG documentation here I can see that you need to take another approach to the SVG Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I was able to figure it out pretty quickly after posing this question, using the 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 Perhaps my only remaining question might be which type I need to declare on the following line: const MyPlusIcon = ({ fill, ...props }) => { It produces the error In the interface IconProps extends PlusIcon.Props {
fill: string;
} to properly define the type for the above erroring line. |
Beta Was this translation helpful? Give feedback.
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:
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 …