I’m creating a new "LayeredButton" component where one button is kind of in front of the other, and the button behind is essentially transparent, and is more-so the div behind both buttons. Basically like so:
Looks exactly how I want it– yay! However, my problem comes from the hovering behaviour– right now when I hover over the Front Button
, it triggers the Behind Button
‘s hover as well, since we are technically hovering over the behind button too.
(You can’t see my mouse but it is over Front Button
)
Here is my essentially my component:
return (
<div className="bg-primary-bold hover:bg-primary-light-500 rounded-full active:bg-primary-bold-600">
<Button
id="left-button"
buttonStyle="primary"
fill="outline"
spacing="hug"
onClick={leftOnClick}
>
{leftLabel}
</Button>
<Button
id="right-button"
buttonStyle="transparent"
fill="link"
spacing="hug"
onClick={rightOnClick}
>
{rightLabel}
</Button>
</div>
);
So basically I want that parent div hover to be ignored if Front Button
‘s hover is active.
Note: The Button
component is also in house so I can edit that code if need be, but it is pretty long and ugly with lots of gross switch statements so I won’t bore you with it here.
2
Answers
For anyone curious, I figured out a solution that was basically what kayla1424 posted, but flipped:
*Note: the :has pseudo-class is not fully supported in Firefox yet.
Another way to do it is to keep the hover style but change the background color of the behind button to its initial background color whenever the front button is hovered.