Glyphicon not working in bootstrap version 4.1 and later

user9644880 picture user9644880 · Apr 18, 2018 · Viewed 34.9k times · Source

I tried to show a search icon in form but the only button is shown without the glyphs.

<form class="form-inline my-2 my-lg-0">
    <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
    <button class="btn btn-outline-success my-2 my-sm-0" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</form>  

RESULT enter image description here

I use bootstrap version 4.1. I got the glyphicon code getbootstrap.com and form getbootstrap.com

Answer

alhelal picture alhelal · Apr 19, 2018

Glyphicons are dropped from Bootstrap V4 and later.

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<form class="form-inline my-2 my-lg-0">
  <div class="input-group">
    <input class="form-control" type="search" placeholder="Search">
    <div class="input-group-append">
      <div class="input-group-text"><i class="fa fa-search"></i></div>
    </div>
  </div>
</form>

Here, Font Awesome is used. Refer this answer for more alternatives to Glyphicons and Font Awesome