0

When attempting to style the webkit scrollbar thumb, polygon works for me but rect does not. I tried recreating this exact svg in normal HTML and it worked, but does not when used as a background-image for this psuedo element. Is it just displaying out of screen or is there something about the rect written incorrectly?

Working code:

&::-webkit-scrollbar-thumb {
    background: #9C9CFF;
    border: ${borderSize}px solid black;

    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='rgb(96, 96, 96)'><polygon points='50,00 0,50 100,50'/></svg>");
}

Broken code: everything the same, just add a rect

&::-webkit-scrollbar-thumb {
    background: #9C9CFF;
    border: ${borderSize}px solid black;

    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='rgb(96, 96, 96)'><polygon points='50,00 0,50 100,50'/><rect width='180' height='180' fill='#000' /></svg>");
}

The polygon disappears as well after adding the rect

If the compilation process may matter, this is code inside of a emotion styled-component, inside react using the basic create-react-app webpack setup.

Without the rect the scrollbar thumb looks like this, with the rect it just has the purple background and no shapes

enter image description here

Connorelsea
  • 2,308
  • 6
  • 26
  • 47

1 Answers1

0

Just figured out why, using hex color codes instead of the rgb(x, y, z) format was breaking the SVG. Not sure why the hex codes didn't work though, so if someone knows I'd be interested to learn

Connorelsea
  • 2,308
  • 6
  • 26
  • 47