The button hoverIndicator property does not work as expected
See original GitHub issueThis is a separate issue, but related to #5680
Expected Behavior
Given that #5680 is fixed or just using JavaScript instead of TypeScript, the button defined as follows:
<Button
primary
label='Click Me!'
onClick={doStuff}
hoverIndicator {{ background: { color: 'red' }, elevation: 'small' }} />
Should have a noticeable shadow when hovered over with the mouse.
Actual Behavior
There is no noticeable shadow. Looking at the actual styles in the browser dev tools I see that the shadow that should have been applied by the elevation: 'small'
property is being overwritten by what is apparently the “default” shadow of the Button
hover state:
.iHgHqy:hover {
background-color: red;
color: #000000;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.20); // <- this is the desired shadow set by the "elevation" property
box-shadow: 0px 0px 0px 2px #439F00; // <- this is the "default" shadow apparently derived from the base button color
}
- Grommet version: 2.18.0
- Browser Name and version: MS Edge
- Operating System and version (desktop or mobile): macOS Big Sur
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
v2 Improve Button docs for hoverIndicator · Issue #3330 - GitHub
The Button 's hoverIndicator prop does not work as the docs say. Expected Behavior. Something like: { dark: { color: 'dark-2', opacity: '1',...
Read more >css - :hover does not seem to be working on custom buttons
I have a couple custom buttons that are working and look fine, except the hover stopped working (should change color on hover.
Read more >Hover and normal state background - General - Forum | Webflow
Hi, For the donation button, I select the Hover state and set the background color opacity to 100%. Then I go to the...
Read more >Styling links - Learn web development | MDN
For example, states like hover can be used to style many different elements, not just links — you might want to style the...
Read more >Understanding SC 1.4.13:Content on Hover or Focus (Level AA)
Where receiving and then removing pointer hover or keyboard focus triggers additional content to become visible and then hidden, the following are true:....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I fixed this initially in #5729, but the PR handled too many concerns so I had to remove it… the box-shadow returned from
getHoverIndicatorStyle
(at src/js/utils/background.js) gets overriden by the box-shadow defined inStyledButton
(at src/js/components/Button/StyledButton.js, line 105) when theplain
prop is falseyHere’s the sandbox link that shows the issue. Open it and then click “Button” under “Controls” on the page shown in preview.
You should see the behavior described. You can also right-click the button, select Inspect, and then force the “hover” state using the browser dev tools and see the styles: