I am having an issue with buttons containing SVG elements, here is an example code snippet:
<button>
Checkout
<ArrowSvg />
</button>
The ArrowSvg component looks like this (with the line having a class of "svg-line"):
<svg fill="none" stroke="#000">
<defs>
<marker id="m" overflow="visible">
<path d="M-4,-4L0,0 -4,4" />
</marker>
</defs>
<line x1="0" y1="50%" x2="100%" y2="50%" marker-end="url(#m)" class="svg-line" />
</svg>
When a button is hovered over, I change the stroke color of the arrow:
btn:hover > .svg-line {
stroke: blue;
}
While this functionality works as expected when only one button is present, issues arise when multiple buttons are displayed. Hovering over one button causes all other button arrows to also change color. This seems to affect the arrow head part of all buttons.
I am unable to use paths instead of lines due to the need for adjusting the arrow width. What might I be missing here? Why is this hover effect spreading to other buttons?