user6718998
user6718998

Reputation:

replace select dropdown arrow with fa-icon

I am trying to replace a select dropdown arrow with a fa-icon (chevron-circle-down) but I can only find that the background can be replaced with an image in the css file.I can add the icon over the select,but it won't be clickable.Any help how I use font icon in select dropdown list ?

Upvotes: 7

Views: 23354

Answers (1)

Mihai T
Mihai T

Reputation: 17687

as you can't use pseudo-elements on <select> you use them on a label instead.

using:

-webkit-appearance: none;
-moz-appearance: none;
appearance: none;

will hide the default down arrow the select has and instead you use the fa-chevron-circle-down icon with it's unicode \f13a as an :after pseudo-element applied to the label

it's not really a 'beautiful' solution, but it does the trick

let me know if it helps

see below snippet

label.wrap {
    width:200px;
    overflow: hidden; 
    height: 50px;    
    position: relative;
    display: block;
    border:2px solid blue;
}

select.dropdown{       
    height: 50px;
    padding: 10px;
    border: 0;
    font-size: 15px;       
    width: 200px;
   -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
label.wrap:after {
    content:"\f13a ";
    font-family: FontAwesome;
    color: #000;
    position: absolute; 
    right: 0; 
    top: 18px;
    z-index: 1;
    width: 10%;
    height: 100%;  
    pointer-events: none;    
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>
<label class="wrap">
    <select class="dropdown">
        <option>Option 1</option>
        <option>Option 2</option>
        <option>Option 3</option>
    </select>
</label>

Upvotes: 14

Related Questions