On Bootstrap 3 this was pretty easy, you just had to change span and add whatever icon you wanted instead. But that doesn't seem the case with Bootstrap 4. Or maybe I'm missing something?
Anyway, here's the basic code for it:
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
Can someone please tell me if it's possible to change the dropdown icon on this and how? I want to add one from fontawesome.
Thank you!
Using the suggestions in the other answers, I added rules in my app's main CSS file for the the dropdown-toggle.
The key is that Bootstrap adds the "collapsed" class to items with "dropdown-toggle" when the content is hidden and removes the class when the content is displayed.
You have to hide the caret icon like this..
Then add the fontawesome icon..
http://www.codeply.com/go/xd2b75iUbM
OR, just remove the
dropdown-toggle
class from the button as it's only purpose seems to be showing the caret icon.I've done something similar to the accepted answer, changing the default caret to a vertical ellipsis from font-awesome like this:
Just apply
dropdown-toggle-ellipsis
as an additional class to your toggle button.The main difference with this solution is that the actual icon (
\f142
here) is now defined in your stylesheets, not in your markup. Whether that's a plus depends on your situation of course.The default caret isn't an icon, rather a border with these properties:
Thus if you set
.dropdown-toggle::after
to haveborder:none!important
, you can the usecontent
to set the icon you want.The code I use is this:
With this method you can also change the FontAwesome icon when the dropdown is visible, thanks to the .show class it adds: