Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Change color of svg used in ::before when :hover on text - Kevin Powell - Community
KP-C
Kevin Powell - Community
•
3y ago
•
6 replies
FryBlaster
Change color of svg used in ::before when :hover on text
Hi everyone
, hope you
're doin well
!
I have the following markup
(sorry
, but I
'm from phone
)
:
<button class
=
"btn
-
-primary
-iconlink
"
>
<span
>Add option
<
/span
>
<
/button
>
And this the css
:
.btn
-
-primary
-iconlink
{
.
.other styles
&
:hover
{
color
: var
(
-
-my
-color
)
;
}
}
.btn
-
-primary
-iconlink
>
s
p
a
n
:
:before
{
content
: url
(my
-image
.svg
)
;
color
: inherit
;
fill
: currentColor
;
}
Basically what I want to achieve is
, when I hover the button
, both the text and svg should change color
. But at the moment only the text does
.
What I
'm doing wrong
? Maybe I should put the icon directly in the html instead
?
Kevin Powell - Community
Join
A friendly place for developers to meet other devs, ask questions, get help, and just have a good time 🙂.
36,263
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Recent Announcements
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
CHANGE COLOR SVG
KP-C
Kevin Powell - Community / front-end
4y ago
Change gradient color on hover
KP-C
Kevin Powell - Community / front-end
4y ago
SVG Component color not changing on hover
KP-C
Kevin Powell - Community / front-end
4y ago
How to change the color of an <svg> image when I hover the mouse
KP-C
Kevin Powell - Community / front-end
3y ago