I have a component that based on certain props I want the ability to change the background on hover. but based on other props, hover should do nothing. is this possible?
export const Container = styled.div`
&:hover {
background: ${({ shouldHover }) => shouldHover ? 'red' : '' };
}
`
however this does not work. any suggestions how this can be done?
This will work:
export const Container = styled.div`
${ props => props.shouldHover
? '&:hover { background: red }'
: ''
}
`;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With