Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font Awesome and Bootstrap 4 Navbar

I am looking for an example of using Fontawesome and the Navbar components of Bootstrap 4 so that I have a text description and an icon next to each other.

like image 362
user3000938 Avatar asked Jan 26 '16 02:01

user3000938


People also ask

Is Font Awesome include in bootstrap 4?

Bootstrap 4 does not have its own icon library (Glyphicons from Bootstrap 3 are not supported in BS4). However, there are many free icon libraries to choose from, such as Font Awesome and Google Material Design Icons.

How do I add FAS FA bars in HTML?

To display Bars font awesome icon, add predefined class name i.e., fa-bars (with prefix fa- ) to the i tag. And we need to add corresponding font awesome icon style for the Bars icon. Bars icon has 1 icon style i.e.,solid. We need to append icon style class fas .


1 Answers

Well, see Bootstrap 4 - Glyphicons migration? in the first place. You can also simply load Font Awesoms' CSS from CDN:

The links in the navbar are just "normal" anchors (a) so you can add the icon inside them:

<a class="nav-link" href="#">
Features<i class="fa fa-bell-o"></i></a>

Example:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<nav class="navbar navbar-light bg-faded">
  <a class="navbar-brand" href="#"><i class="fa fa-stack-overflow"></i>Navbar</a>
  <ul class="nav navbar-nav">
    <li class="nav-item active">
      <a class="nav-link" href="#"><i class="fa fa-home"></i>
Home <span class="sr-only">(current)</span></a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#">
Features<i class="fa fa-bell-o"></i></a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#"><i class="fa fa-btc"></i>
Pricing</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#"><i class="fa fa-user-plus"></i>
About</a>
    </li>
  </ul>
  <form class="form-inline pull-xs-right">
    <input class="form-control" type="text" placeholder="Search">
    <button class="btn btn-success-outline" type="submit"><i class="fa fa-search"></i>
Search</button>
  </form>
</nav>

To add a search icon in the placeholder of the search form, see: Use Font Awesome Icon in Placeholder

like image 62
Bass Jobsen Avatar answered Sep 29 '22 17:09

Bass Jobsen