-
I want to make my own custom button to fit specific use-cases. I want my button to apply specific style to children component given a In css the result would be: .Button:hover > .Icon,
.Button:hover > .Text {
color: red
} Here's my use-case export type ButtonProps = BoxProps & {
label: string
iconName: string
type: 'primary' | 'secondary'
}
export const Button: FC<ButtonProps> = ({ label, iconName, type }) => {
const color = 'primary' ? 'blue' : 'gray'
return (
<PseudoBox
_hover={{
'&>div': { color: red }
}}
>
<Icon name={iconName} color={color} />
<Text color={color}>{label}</Text>
</PseudoBox>
)
} Maybe the new major (v1.0.0) of Chakra-ui will fix this issue |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
@gamegee You could make this a lot easier on yourself by moving |
Beta Was this translation helpful? Give feedback.
-
For my use-case it can do the work, but what if I want the |
Beta Was this translation helpful? Give feedback.
-
I found a way to do this using export type ButtonProps = BoxProps & {
label: string
iconName: string
type: 'primary' | 'secondary'
}
export const Button: FC<ButtonProps> = ({ label, iconName, type }) => {
const color = 'primary' ? 'blue' : 'gray'
return (
<PseudoBox
role="group"
>
<Icon name={iconName} color={color} _groupHover={{color: 'red' }} />
<Text color={color} _groupHover={{color: 'yellow' }}>{label}</Text>
</PseudoBox>
)
} |
Beta Was this translation helpful? Give feedback.
-
Im also facing this issue, the above suggestions do work, however in my case I building a custom radio button, well, more a super select. I want the radio button to take its hover state when hovering anywhere in the super select item. I can't apply Any suggestions? I don't want to send the styles down into the Radio, I want the ability to tell the Radio - 'Behave like you are being hovered over' |
Beta Was this translation helpful? Give feedback.
I found a way to do this using
_groupHover
: