-
I have an Example<ButtonGroup>
<Button rightIcon={<Icon _groupHover={{ color: "red.500" }} />}>
Click
</Button>
<IconButton icon={<Icon _groupHover={{ color: "green.500" }} />} />
</ButtonGroup> The problem is that CodeSandBox Link: https://codesandbox.io/s/tender-poitras-oc206?file=/src/index.js |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Hi Hazem, This is my solution: https://codesandbox.io/s/blazing-grass-y5m4j?file=/src/index.js I had to wrap the text in the button with the |
Beta Was this translation helpful? Give feedback.
-
There's a way to do this without state. <ButtonGroup sx={{ '.but:hover ~ .ico' : { color: 'green.500' } }}>
<Button className="but" rightIcon={<Icon />}>
Click
</Button>
<IconButton icon={<Icon className="ico" />} />
</ButtonGroup> |
Beta Was this translation helpful? Give feedback.
-
What I ended up doing was add to my then used it as a selector {
'[data-component-name="Button"]:hover &': {
color: "green.500"
}
} Quite pragmatic, I think every component in Chakra-UI should have a |
Beta Was this translation helpful? Give feedback.
-
@hazem3500 fyi you can also do this:
Docs: https://chakra-ui.com/docs/styled-system/style-props#pseudo |
Beta Was this translation helpful? Give feedback.
What I ended up doing was add to my
Button
component an attributedata-component-name="Button"
then used it as a selector
Quite pragmatic, I think every component in Chakra-UI should have a
data-component-name
attribute as an escape-hatch