svg-sprite icon indicating copy to clipboard operation
svg-sprite copied to clipboard

How do I style an individual path in an SVG with CSS?

Open jackdomleo7 opened this issue 4 years ago • 3 comments

image

The SVG is hidden inside shadow-root.

I have some SCSS, that I want to change the colour of each path when the SVG is hovered:

svg {
  &:hover {
    path {
      &:nth-child(1) {
        fill: #00C58E;
      }

      &:nth-child(2) {
        fill: #2F495E;
      }

      &:nth-child(3) {
        fill: #108775;
      }
    }
  }
}

But this doesn't work because of shadow-root. What's the best way to achieve this? 🙂

jackdomleo7 avatar Jun 29 '20 16:06 jackdomleo7

Hey 🙂 Sorry for the late response
There is no perfect solution for changing svg styles for now. You can use two svg icon and change icons name on hover.

farnabaz avatar Oct 04 '20 10:10 farnabaz

Ok thank you! Is this a feature that may be implemented in the near future? 🙂

jackdomleo7 avatar Oct 04 '20 20:10 jackdomleo7

Supporting this feature will be tricky because different browsers have different behaviors.

farnabaz avatar Oct 04 '20 23:10 farnabaz