Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap5 Input Group

Bootstrap5 Input Group

We can use the .input-group class to add more styles to form inputs, such as icons, text or buttons.

The .input-group-text class sets the style of the text..

Bootstrap Examples

<form>
<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">
<input type="text" class="form-control" placeholder=">

Your Email

"

<

span

class

=

"

input-group-text

"

@runoob.com

span

div

form

Try it »


Input Group Sizing

Use the .input-group-sm class for small input groups and the .input-group-lg class for large input groups:

Bootstrap Examples

<div class=">

input-group mb-3 input-group-sm

"

<span class="input-group-text" Small span>
<input type="text" class="form-control" div>
<div class=">

input-group mb-3

"

<span class="input-group-text" Default span>
<input type="text" class="form-control" div>
<div class=">

input-group mb-3 input-group-lg

"

<span class="input-group-text" Large span>
<input type="text" class="form-control" div>

Try it »


Multiple Inputs and Text

Bootstrap Examples

<div class=">

input-group mb-3

"

<span class="input-group-text" Person span>
<input type="text" class="form-control" placeholder=">

First Name

"

<input type="text" class="form-control" placeholder=">

Last Name

"

div

<div class=">

input-group mb-3

"

<span class="input-group-text" One span>
<span class="input-group-text" Two span>
<span class="input-group-text" Three span>
<input type="text" class="form-control" div>

Try it »


Checkboxes and Radios

Text information can be replaced with checkboxes and radios:

Bootstrap Examples

<div class=">

input-group mb-3

"

<div class="input-group-text">
<input type="checkbox" div>
<input type="text" class="form-control" placeholder="RUNOOB" div>
<div class=">

input-group mb-3

"

<div class="input-group-text">
<input type="radio" div>
<input type="text" class="form-control" placeholder="GOOGLE" div>

Try it »


Adding Buttons to Input Groups

Bootstrap Examples

<div class=">

input-group mb-3

"

<button class=">

btn btn-outline-primary

"

type

=

"

button

"

Basic Button

button

<input type="text" class="form-control" placeholder=">

Some text

"

div

<div class=">

input-group mb-3

"

<input type="text" class="form-control" placeholder="Search">
<button class=">

btn btn-success

"

type

=

"

submit

"

Go

button

div

<div class=">

input-group mb-3

"

<input type="text" class="form-control" placeholder=">

Something clever..

"

<button class=">

btn btn-primary

"

type

=

"

button

"

OK

button

<button class=">

btn btn-danger

"

type

=

"

button

"

Cancel

button

div

Try it »


Adding Dropdowns

Adding a dropdown to an input group does not require the .dropdown class.

Bootstrap Examples

<div class=">

input-group mt-3 mb-3

"

<button type="button" class=">

btn btn-primary dropdown-toggle

"

data-bs-toggle

=

"

dropdown

"

Select Website

button

<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="https://www.google.com" GOOGLE a li>
<li>
<a class="dropdown-item" href="https://www.runoob.com" RUNOOB a li>
<li>
<a class="dropdown-item" href="https://www.taobao.com" TAOBAO a li ul>
<input type="text" class="form-control" placeholder=">

Website Address

"

div

Try it »


Input Group Labels

Set a label for an input group via a label outside the group; the label's for attribute must match the input group's id. Clicking the label will focus the input:

Bootstrap Examples

<form>
<label for="demo">

Enter your email here:

label

<div class=">

input-group mb-3

"

<input type="text" class="form-control" placeholder="Email" id="demo" name="email">
<span class="input-group-text" @runoob.com span div form>

Try it »