Adding gradient color to font awesome icon seems easy generally, just apply the following css:
background: -webkit-linear-gradient(#9c47fc, #356ad2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
But for some reason I cannot make it happen in React. my jsx is:
<FontAwesomeIcon className="audio-icon" icon="step-backward" />
And the css:
.audio-icon {
font-size: 20rem;
text-align: center;
position: absolute;
background: -webkit-linear-gradient(#9c47fc, #356ad2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
The gradient doesn't apply. if I use !important:
background: -webkit-linear-gradient(#9c47fc, #356ad2) !important;
It applies to the background, but I cannot add !important to the webkit-background-clip and webkit-text-fill-color
Also, trying to to select the psuedo element .audio-icon::before doesn't do anything.
Any ideas?
Thanks in advance
I'm not sure whether it's a problem with font aswesome npm for react, but anyhow the work around is to just do it the old way: 1. Add the cdn link to index.html 2. use the normal html syntax:
<i className="fas fa-step-backward audio-icon"></i>
If someone happens to know how to apply it with the npm package for React I would appreciate it
Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With