The issue is that fill: currentColor
isn’t a valid attribute for pseudo-elements like ::before
. Instead, you can add the color directly inside the SVG element.
Here’s how you can do that for black as the normal state color and white for the hover state:
- Insert
fill="#000"
into your SVG:
<svg xmlns="https://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path fill="#000" d="M220-180h150v-250h220v250h150v-390L480-765 220-570v390Zm-60 60v-480l320-240 320 240v480H530v-250H430v250H160Zm320-353Z"/></svg>
- Convert this SVG to a Data URI using https://yoksel.github.io/url-encoder/ and insert the encoded SVG into your CSS:
.button-icon a.wp-block-button__link::before {
content: "";
display: inline-block;
height: 24px;
width: 24px;
background-image: url("data:image/svg+xml, {your encoded SVG here}");
background-repeat: no-repeat;
background-position: center;
background-size: contain;
margin-right: 8px;
vertical-align: middle;
}
- Next, prepare the SVG for the hover state by changing the fill color to
#fff
:
<svg xmlns="https://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path fill="#fff" d="M220-180h150v-250h220v250h150v-390L480-765 220-570v390Zm-60 60v-480l320-240 320 240v480H530v-250H430v250H160Zm320-353Z"/></svg>
- Again, convert this SVG to a Data URI and insert the encoded SVG into your CSS:
.button-icon a.wp-block-button__link:hover::before {
background-image: url("data:image/svg+xml, {your encoded SVG here}");
}
Hope that helps ??