Bootstrap 5: Text Input with Button

Ruth Jul 09, 2026

Bootstrap, a popular open-source CSS framework, offers a wide range of pre-built components to simplify the development of responsive and mobile-first websites. One of its most fundamental elements is the text input with a button, a staple in form design. In this guide, we'll delve into creating a Bootstrap 5 text input with a button, exploring its various aspects and best practices.

📝 Create Text Input Forms and Submit Button in HTML
📝 Create Text Input Forms and Submit Button in HTML

Before we dive into the code, let's briefly discuss why using Bootstrap for form elements is beneficial. Bootstrap's components are not only responsive but also highly customizable, ensuring your forms look great and function well across different devices and screen sizes.

Bootstrap 5 Buttons with Icon and Text Tutorial & Demo — CodeHim
Bootstrap 5 Buttons with Icon and Text Tutorial & Demo — CodeHim

Setting Up the Bootstrap Environment

To start using Bootstrap 5, you'll first need to include it in your project. You can either download the source files or use a CDN (Content Delivery Network). For this guide, we'll use the CDN.

A Beginner's Guide to the Latest Bootstrap 5 Utilities
A Beginner's Guide to the Latest Bootstrap 5 Utilities

Add the following lines in the section of your HTML file:

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>

Creating a Basic Text Input with Button

the bootstrap text colors list is shown in purple, orange and green tones
the bootstrap text colors list is shown in purple, orange and green tones

Now that we have Bootstrap set up, let's create a simple text input with a button. Wrap the input and button inside a Bootstrap form:

<form>
  <div class="input-group mb-3">
    <input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username">
    <button class="btn btn-outline-secondary" type="button">Button</button>
  </div>
</form>

The input-group class applies Bootstrap's input group styles, ensuring the input and button are properly aligned. The btn and btn-outline-secondary classes style the button.

Customizing the Input and Button

GoSnippets — Free Code Snippets for Bootstrap, Tailwind, React, CSS, JavaScript & more
GoSnippets — Free Code Snippets for Bootstrap, Tailwind, React, CSS, JavaScript & more

Bootstrap provides several customization options for inputs and buttons. Let's explore a few:

Input Sizes

You can change the input size using the size class. Add .form-control-lg or .form-control-sm to the input:

HTML Input Types Demo
HTML Input Types Demo

<input type="text" class="form-control form-control-lg" ...>

Button Variants

Bootstrap offers various button variants. Replace btn-outline-secondary with another variant, such as btn-primary or btn-danger:

Button hover effect
Button hover effect
an image of buttons and labels on a computer screen
an image of buttons and labels on a computer screen
a blue button with the words ask me anything on it and an arrow pointing up
a blue button with the words ask me anything on it and an arrow pointing up
How to Create Bootstrap 5 Navigation Header? – WebNots
How to Create Bootstrap 5 Navigation Header? – WebNots
botĂłn web, botĂłn degradado
botĂłn web, botĂłn degradado
Full-width Split Button Dropdown in Bootstrap
Full-width Split Button Dropdown in Bootstrap
20+ Best Free Web Button Templates To Boost Your UI Design (2026 Update) - 365 Web Resources
20+ Best Free Web Button Templates To Boost Your UI Design (2026 Update) - 365 Web Resources
two screens showing the different types of text in an open - source web page, with one being highlighted
two screens showing the different types of text in an open - source web page, with one being highlighted
a white and blue web page with different types of buttons
a white and blue web page with different types of buttons
Bootstrap Add Rows To Table
Bootstrap Add Rows To Table
HTML Input Types : A Comprehensive Guide
HTML Input Types : A Comprehensive Guide
BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP
BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP
the different buttons are highlighted in this image
the different buttons are highlighted in this image
button hover effects, html and css
button hover effects, html and css
an orange background with some type of text in the bottom right corner and another type of text below
an orange background with some type of text in the bottom right corner and another type of text below
a set of colorful buttons and buttons on a dark background with space for text illustration
a set of colorful buttons and buttons on a dark background with space for text illustration
Stop Googling HTML Inputs—Save This Instead!
Stop Googling HTML Inputs—Save This Instead!
HTML Input Types – Complete Guide for Beginners
HTML Input Types – Complete Guide for Beginners
Bootstrap Buttons Set
Bootstrap Buttons Set
two text messages are shown with the same message in each one's speech box
two text messages are shown with the same message in each one's speech box

<button class="btn btn-primary" type="button">Button</button>

Adding Icons to the Button

Adding icons to buttons can enhance their functionality and aesthetics. Bootstrap uses Font Awesome for icons, so you'll need to include Font Awesome in your project:

Add this line in the section of your HTML file:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">

Using Font Awesome Icons

Now, let's add an icon to our button. Replace the button code with the following:

<button class="btn btn-primary" type="button">
  <i class="fas fa-search"></i>
</button>

The fa-search icon is used here, but you can replace it with any Font Awesome icon.

Button with Icon and Text

You can also add text alongside the icon. Update the button code as follows:

<button class="btn btn-primary" type="button">
  <i class="fas fa-search"></i> Search
</button>

With these customization options, you can create text inputs with buttons that perfectly fit your project's design and functionality needs.

In conclusion, Bootstrap 5 simplifies the creation of text inputs with buttons, offering a wide range of customization options. By leveraging Bootstrap's pre-built components and styles, you can enhance your forms' appearance and responsiveness. So, start exploring and building today!