Icon in bootstrap 4 inside the input

bootstrap input-group multiple inputs
bootstrap search box with icon inside
icon inside input
bootstrap 4 input
bootstrap 4 icon with text
search input with bootstrap 4
button inside input bootstrap
bootstrap 4 icons

I am looking for a solution to create and input like this one in bootstrap 4

I am using font awesome and this is the code that I use

<div class="input-group">
    <label class="control-label">Username</label>
    <input type="text" class="form-control" placeholder="Username" />
    <span>
        <i class="fa fa-user-circle-o" aria-hidden="true"></i>
    </span>
</div>

but i get the image out of the input Any help please https://jsfiddle.net/5db2ho62/

You don't need to have the icon inside the input- you can place it next to the input field, and remove the input field's border using CSS.

HTML:

<div class="input-group">
<i class="fa fa-user-circle-o"></i>
<input type="text" class="form-control" placeholder="Enter Name Here" >
</div>

CSS:

input{
  border:none;
  background-color: transparent;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: none;
}

.fa-user-circle-o{
  color: gray;
}

Updated fiddle: https://jsfiddle.net/5db2ho62/2/

Search input with an icon Bootstrap 4, And, you can make it appear inside the input using the border utils <div class="​input-group col-md-4"> <input class="form-control py-2  Bootstrap 4 Input Groups The .input-group class is a container to enhance an input by adding an icon, text or a button in front or behind the input field as a "help text". Use .input-group-prepend to add the help text in front of the input, and .input-group-append to add it behind the input.

here is the solution

span{
  position: absolute;
  margin-left: 5px;
  height: 25px;
  display: flex;
  align-items: center;
}
input{
  padding-left: 25px;
  height: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<div class="input-group">
  <span>
    <i class="fa fa-user-circle-o" aria-hidden="true"></i>
  </span>
  <input type="text" class="form-control" placeholder="Username" />
</div>

bootstrap icon inside input, <p class="font-weight-bold">Different usage of the icons inside the inputs and forms.</p>. 4. ​. 5. <p><strong>Detailed documentation and more examples you​  How to add an icon to input submit button in Bootstrap. Topic: Bootstrap / Less Prev|Next Answer: Use the CSS position Property. Since, the <input> is an empty element, we cannot place the icon HTML directly inside the input button like we do with the buttons created using the <button> element.

This method seems to be the cleanest. You do not need to add any custom CSS. You can do the following all with Bootstrap:

$(document).ready(function() {
  $('.input-focus').on('click', function() {
    $(this).children('input').focus();
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">

<div class="input-group input-focus">
  <div class="input-group-prepend">
    <span class="input-group-text bg-white"><i class="fa fa-search"></i></span>
  </div>
  <input type="search" placeholder="Search" class="form-control border-left-0">
</div>

Bootstrap 4 Icon in Input, <div class="input-group mt-4">. <input class="form-control border-right-0">. <​span class="input-group-append bg-white">. <button class="btn border  How to enable/disable all input controls inside a form element using jQuery ? How to place Font Awesome icon to input field ? How to replace dropdown-toggle icon with another default icon in Bootstrap ? Design a form component which takes input from its user and displays a form; How to put a responsive clear button inside HTML input text field ?

.main {
    width: 50%;
    margin: 50px auto;
}

.form-group .form-control {
    padding-left: 2.375rem;
}

.form-group .form-control-icon {
    position: absolute;
    z-index: 2;
    display: block;
    width: 2.375rem;
    height: 2.375rem;
    line-height: 2.375rem;
    text-align: center;
    pointer-events: none;
    color: #aaa;
}
<link id="bootstrap-css" href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">

<div class="main">
  <div class="form-group">
    <span class="fa fa-search form-control-icon"></span>
    <input type="text" class="form-control" placeholder="Search">
  </div>  
</div>

Input group · Bootstrap, Bootstrap 4 Input Groups. The .input-group class is a container to enhance an input by adding an icon, text or a button in front or behind the input field as a "​help  Bootstrap supports all the HTML5 input types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color. Note: Inputs will NOT be fully styled if their type is not properly declared! The following example contains two input elements; one of type="text" and one of type="password". As we

The solution is maybe to use unicode in placeholder. Here the cheatsheet for all font awesome unicode http://fontawesome.io/cheatsheet/

input {
  padding:10px;
  font-family: FontAwesome, "Open Sans", Verdana, sans-serif;
  font-style: normal;
  font-weight: normal;
  text-decoration: inherit;
}
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="input-group">
  <label class="control-label">Username</label>
  <input type="text" class="form-control" placeholder="&#xf075; Username" />
</div>

Bootstrap 4 Form Input Group, Making a text input with a search icon from Font Awesome in Bootstrap 4. Great for search boxes on the websites powered by Bootstrap 4. Requires at lea As beard of prey points out, you can do this with CSS by absolutely positioning the icon inside of the input element. Then add padding to either side so the text doesn't overlap with the icon. Then add padding to either side so the text doesn't overlap with the icon.

Bootstrap 4 text input with search icon, We can prepend or append text or HTML to the field by wrapping the input with a .input-group <div> and then including a .input-group-addon  Bootstrap Input Groups The .input-group class is a container to enhance an input by adding an icon, text or a button in front or behind it as a "help text". The .input-group-addon class attaches an icon or help text next to the input field.

How to Add Icons to Your Bootstrap Form, Font Awesome icon placement when used in Bootstrap input with Currently with Font Awesome and Bootstrap 4, I have the following problem  Bootstrap 3 Placing Icon inside input field. Ask Question I am working in Bootstrap 3 and am trying to get a calendar icon inside the right hand side of the input

Font Awesome icon placement when used in Bootstrap input with , This uses bootstrap 4 and font awesome CSS files. In HTML .input-groups are used, which is class is a container to enhance an input by adding an icon, text or a  When attempting to use Font-Awesome icons within a Bootstrap input with feedback, the placement is off: Font-Awesome is overwriting a couple of rules that fix this alignment: The work Edit: Use the fix from @Azaret below, it works great!

Comments
  • Create a fiddle. I can edit that
  • can you describe what you're trying to achieve? the image you provided doesn't load (also, for future generation's sake you shouldn't rely on images in SO)
  • @SyamPillai SO has built-in snippets now; there's no reason to link outside the site in this instance
  • The span tag should have the class input-group-addon. Then overwrite the style with CSS. Make sure the span line is above the input line
  • Can you provide your custom CSS additions as well? They may be interfering with Bootstrap
  • but i need it to have a border like the image above
  • @MohamedSherifNoureldin You can add a border to the outer div, it would look the same- updated fiddle
  • This answer is not great. UX would expect clicking anywhere in the bordered area to select the input to start editing. Input should hold the border, and have padding for the icon to be positioned within, such that a click on the icon also selects the input.
  • The downside with this approach is the selected state of the input does not cover the entire "apparent" element. My expectation would be that the icon is contained inside the input, such that a click on the icon also clicks the search field.
  • @mix3d I agree with the downside you mentioned and think it is better UX to have the icon focus the input. This is easily achieved with a small bit of JavaScript. I've added an update to the answer.
  • But the focus state still doesn't cover the entire "field". Visually, the icon is "inside" the input field, and as such, I would expect the focus state to include the icon's area