Bootstrap, the popular CSS framework, offers a wide range of pre-built components to simplify and speed up web development. One of these components is the input group, which helps combine form controls and add-ons like buttons, dropdowns, and labels in a single, elegant element. Let's explore some practical examples of Bootstrap input groups.

Before diving into the examples, ensure you have included the Bootstrap CSS and JavaScript files in your project. You can download them from the official Bootstrap website or use a CDN link. Once you've set up the necessary files, you can start building your input groups.

Basic Input Group Example
The most fundamental input group consists of an input field and an add-on, such as a button or an icon. Here's a simple example:

<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" class="form-control" placeholder="Username">
</div>
Input Group with Buttons

Input groups can also include buttons. In this example, we'll add buttons on both sides of the input field:
<div class="input-group mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary" type="button" id="button-addon1">Button 1</button>
</div>
<input type="text" class="form-control" placeholder="Recipient's username">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="button-addon2">Button 2</button>
</div>
</div>
Input Group with Dropdown

Input groups can also incorporate dropdown menus. Here's an example of an input group with a dropdown button:
<div class="input-group mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
<input type="text" class="form-control" placeholder="Dropdown input">
</div>
Input Group Sizing

Bootstrap provides several pre-defined sizes for input groups, allowing you to create responsive and visually consistent forms. Let's explore some size variations:
Default Size




















The default size for input groups is 'md', which is suitable for most use cases. Here's an example of a default-sized input group:
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" class="form-control" placeholder="Default input">
</div>
Large Input Group
To create a larger input group, use the 'lg' class. This size is ideal for inputs that require more space, such as those used in search bars:
<div class="input-group input-group-lg mb-3">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" class="form-control" placeholder="Large input">
</div>
Small Input Group
For inputs that require less space, such as those used in compact forms, use the 'sm' class to create a smaller input group:
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" class="form-control" placeholder="Small input">
</div>
With these examples, you now have a solid foundation for creating and customizing input groups in your Bootstrap projects. Experiment with different add-ons, sizes, and configurations to create unique and engaging user interfaces. Happy coding!