Input Groups & Floating Labels
Input Groups
An input group attaches text, an icon or a button to an input. Examples are the @ sign before a username or a Search button next to a search field.
html
<div class="input-group mb-3">
<span class="input-group-text">@</span>
<input type="text" class="form-control" placeholder="Username">
</div>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Amount">
<span class="input-group-text">.00</span>
</div>
<div class="input-group mb-3">
<span class="input-group-text">$</span>
<input type="number" class="form-control">
<span class="input-group-text">USD</span>
</div>
With Buttons
html
<div class="input-group">
<input type="text" class="form-control" placeholder="Search courses">
<button class="btn btn-primary" type="button">
<i class="bi bi-search"></i> Search
</button>
</div>
Result
A search field with a blue button attached directly to its right side.
With Icons
html
<div class="input-group">
<span class="input-group-text"><i class="bi bi-envelope"></i></span>
<input type="email" class="form-control" placeholder="Email">
</div>
Sizes
html
<div class="input-group input-group-lg">...</div>
<div class="input-group input-group-sm">...</div>
Floating Labels
A floating label sits inside the input like a placeholder, and floats up and shrinks when you type. It looks modern and saves vertical space.
html
<div class="form-floating mb-3">
<input type="email" class="form-control" id="fEmail" placeholder="name@example.com">
<label for="fEmail">Email address</label>
</div>
<div class="form-floating mb-3">
<input type="password" class="form-control" id="fPass" placeholder="Password">
<label for="fPass">Password</label>
</div>
<div class="form-floating">
<select class="form-select" id="fSelect">
<option>One</option>
<option>Two</option>
</select>
<label for="fSelect">Choose</label>
</div>
Important: In floating labels, the
placeholder attribute must exist (even if you do not need the text), and the label must come after the input.
Conclusion
Input groups and floating labels give forms a modern, polished look. Use input groups when a symbol or button belongs to the field.
Quick Summary: input-group with input-group-text or buttons joins elements, and form-floating with input then label creates floating labels.

