Bootstrap 5 Form Input with Icon: Enhance User Experience

Ruth Jul 09, 2026

Form inputs are a crucial aspect of web development, and when it comes to Bootstrap 5, the framework provides a wide range of pre-built components to streamline this process. One such component is the form input with an icon, which adds a touch of visual appeal and enhances user experience. Let's delve into the intricacies of form input with icon in Bootstrap 5.

Free 22+ HTML5 Signup & Registration Forms - HTML, CSS
Free 22+ HTML5 Signup & Registration Forms - HTML, CSS

Before we dive into the specifics, it's essential to understand that Bootstrap 5 uses a utility-first approach, which means that instead of predefined components, it offers a set of utilities that can be combined to build complex components. This approach provides more flexibility and customization options.

37 Free Bootstrap Form Templates You Can Try Right Now
37 Free Bootstrap Form Templates You Can Try Right Now

Understanding Form Input with Icon in Bootstrap 5

In Bootstrap 5, a form input with an icon is essentially a combination of a form input and an icon. The icon can be used to provide visual feedback or to indicate the type of input expected. For instance, a search icon in a form input field suggests that the user should type a search query.

Bootstrap Forms
Bootstrap Forms

Bootstrap 5 uses the Font Awesome library for icons by default. However, you can replace it with any other icon font library of your choice. To use an icon with a form input, you need to combine the input utility classes with the icon utility classes.

Adding an Icon to the Left of a Form Input

📝 Create Forms in HTML
📝 Create Forms in HTML

To add an icon to the left of a form input, you can use the 'me-2' utility class to create some space between the icon and the input, and the 'bi' class to specify the icon. Here's an example:

<div class="input-group mb-3"> <span class="input-group-text"> <i class="bi bi-search me-2"></i> </span> <input type="text" class="form-control" placeholder="Search"> </div>

In this example, the 'bi bi-search' class is used to specify the search icon from the Font Awesome library. The 'me-2' class adds some margin to the right of the icon, creating space between the icon and the input field.

BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP
BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP

Adding an Icon to the Right of a Form Input

Adding an icon to the right of a form input is similar to adding one to the left. You just need to use the 'ms-2' utility class instead of 'me-2' to create some space between the icon and the input. Here's an example:

<div class="input-group mb-3"> <input type="text" class="form-control" placeholder="Username"> <span class="input-group-text"> <i class="bi bi-person me-2"></i> </span> </div>

AdminKit PRO - Bootstrap 5 Admin Template
AdminKit PRO - Bootstrap 5 Admin Template

In this example, the 'bi bi-person' class is used to specify the person icon from the Font Awesome library. The 'ms-2' class adds some margin to the left of the icon, creating space between the icon and the input field.

Customizing Form Input with Icon in Bootstrap 5

Wizard
Wizard
Bootstrap 5 responsive registration form
Bootstrap 5 responsive registration form
📝 Create Text Input Forms and Submit Button in HTML
📝 Create Text Input Forms and Submit Button in HTML
the bootstap login and register forms page
the bootstap login and register forms page
the new html form is displayed in this screenshote, and it appears to be different
the new html form is displayed in this screenshote, and it appears to be different
40 Best Free Bootstrap Login Form Templates 2026 - Colorlib
40 Best Free Bootstrap Login Form Templates 2026 - Colorlib
two screens showing the user's options for different types of text and numbers on each screen
two screens showing the user's options for different types of text and numbers on each screen
Add remove input fields dynamically using jQuery and bootstrap
Add remove input fields dynamically using jQuery and bootstrap
Sign In, Log In, Sign Up, Mobile App Design, Ul design,
Sign In, Log In, Sign Up, Mobile App Design, Ul design,
two screens showing the settings and options for each user's website page, with one being
two screens showing the settings and options for each user's website page, with one being
an image of the user's name and number on their website page, which is highlighted in red
an image of the user's name and number on their website page, which is highlighted in red
the account screen is open and shows an image of a man's profile
the account screen is open and shows an image of a man's profile
Login, signup and verify user registation pages for web and mobile | Premium PSD
Login, signup and verify user registation pages for web and mobile | Premium PSD
two screens showing the user's information page
two screens showing the user's information page
HTML/CSS|Formの使い方(label, input, select, textarea) - わくわくBank
HTML/CSS|Formの使い方(label, input, select, textarea) - わくわくBank
Form Fields
Form Fields
an image of a web page with different types of buttons and numbers on the screen
an image of a web page with different types of buttons and numbers on the screen
UI Designer’s Guide to Creating Forms & Inputs
UI Designer’s Guide to Creating Forms & Inputs
How To Create Responsive Registration Form in HTML & CSS
How To Create Responsive Registration Form in HTML & CSS
Form UX tip: Fewer fields = less friction.
Form UX tip: Fewer fields = less friction.

While the default form input with icon in Bootstrap 5 is quite versatile, you might want to customize it to fit your specific needs. This could involve changing the color, size, or style of the icon, or adding additional functionality to the input field.

To customize the icon, you can use the icon utility classes provided by Bootstrap 5. For example, to change the color of an icon, you can use the 'text-primary', 'text-secondary', etc. classes. To change the size of an icon, you can use the 'fs-2', 'fs-3', etc. classes. Here's an example:

<div class="input-group mb-3"> <span class="input-group-text text-primary fs-3"> <i class="bi bi-search me-2"></i> </span> <input type="text" class="form-control" placeholder="Search"> </div>

In this example, the 'text-primary' class is used to change the color of the icon to blue, and the 'fs-3' class is used to increase the size of the icon.

Adding Functionality to Form Input with Icon

To add functionality to a form input with icon, you can use JavaScript or jQuery. For example, you might want to add a click event to the icon that triggers a search function. Here's an example using jQuery:

<div class="input-group mb-3"> <input type="text" class="form-control" id="searchInput" placeholder="Search"> <span class="input-group-text"> <i class="bi bi-search me-2" id="searchIcon"></i> </span> </div>

In this example, the 'id' attribute is used to give the input field and the icon unique identifiers. Then, in your JavaScript or jQuery code, you can add a click event listener to the icon that triggers a search function:

$('#searchIcon').click(function() { var searchQuery = $('#searchInput').val(); // Perform search function with searchQuery });

In conclusion, form input with icon in Bootstrap 5 is a powerful tool that can enhance the user experience and provide visual feedback. With a bit of creativity and customization, you can create form inputs that are not only functional but also aesthetically pleasing. So, go ahead and explore the possibilities of form input with icon in Bootstrap 5!