After upgrading to FontAwesome 5, I'm not able to color the svgs of FontAwesome.
This is my example:
⠀⠀⠀⠀⠀
https://codepen.io/shadrix/pen/GygdZr
Should be awesome if it worked like here: ⠀⠀⠀⠀⠀
https://codepen.io/immad-hamid/pen/jVNvQO (Note: he used FontAwesome 4).
Icons are no longer referenced as glyphs from a font, but injected as inline SVG. The content color of the icon is defined as
fill="currentColor"
.The technique with setting the background and using
-webkit-background-clip
no longer works. Instead you can set thecolor
property directly. Unfortunately, that is where you get into a bit of trouble becausecolor
does not support gradients. You can setfill
instead, if you use a SVG gradient definition:THe
r
attribute for the gradient cannot be expressed in the same terms as in CSS, so it's a bit of an estimate here.Note the selector
div:hover svg *
. with that, it overwrites the attribute on the element. It needs to reference the styled element directly, if inheriting that style,fill="currentColor"
would have the higher specificity.use like this