I'm running a React application and I need to render a FontAwesome icon inside of a select form field like in this Codepen
To achieve this, I'm using CSS Pseudo Elements, :after to be specific as defined here
Unfortunately, this works well inside of this CodePen but it doesn't render inside the div on my app. I get a box to show that the FontAwesome icon didn't render and the actual icon appears after the select input. See image below for what it looks like.
CSS
.selectdiv {
position: relative;
}
.selectdiv:after {
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f107";
color: rgb(75,173,233);
right: 0rem;
top: 0.3rem;
height: 2rem;
padding: 0rem 0rem 0rem 0rem;
position: absolute;
pointer-events: none;
}
/* IE11 hide native button*/
select::-ms-expand {
display: none;
}
.selectdiv select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
color: rgb(75,173,233);
background-color: #ffffff;
background-image: none;
-ms-word-break: normal;
word-break: normal;
}
index.html
<!-- FontAwesome Pseudo Elements Config -->
<script src="https://use.fontawesome.com/releases/v5.12.0/js/all.js" data-search-pseudo-elements></script>
<script>
window.FontAwesomeConfig = {
searchPseudoElements: true
}
</script>