Bootstrap Input Groups

Bootstrap is a free and open source front end development framework for the creation of websites and web apps.
Site Admin
Posts: 159
Joined: Sun Jun 26, 2022 10:46 pm

Bootstrap Input Groups

Post by C0D3D »

Prepend and append inputs with Bootstrap

Example 1

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Prepend and Append Inputs</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="m-4">
    <div class="row g-2">
        <div class="col-6">
            <div class="input-group">
                <span class="input-group-text">
                    <span class="bi-person"></span>
                </span>
                <input type="text" class="form-control" placeholder="Username">
            </div>
        </div>
        <div class="col-6">
            <div class="input-group">            
                <input type="text" class="form-control" placeholder="Amount">
                <span class="input-group-text">.00</span>
            </div>
        </div>
        <div class="col-6">
            <div class="input-group">
                <span class="input-group-text">https://www.</span>
                <input type="text" class="form-control" placeholder="Domain name">
            </div>
        </div>
        <div class="col-6">
            <div class="input-group">
                <span class="input-group-text">$</span>
                <input type="text" class="form-control" placeholder="US Dollar">
                <span class="input-group-text">.00</span>
            </div>
        </div>
    </div>
</div>
</body>
</html>

Prepend and append select box and textarea with Bootstrap

Example 2

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Prepend and Append Select Box and Textarea</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="m-4">
    <div class="row g-2">
        <div class="col-12">
            <div class="input-group">            
                <span class="input-group-text">Address</span>
                <textarea class="form-control"></textarea>
            </div>
        </div>
        <div class="col-6">
            <div class="input-group">
                <label class="input-group-text">Country</label>
                <select class="form-select">
                    <option selected>Choose...</option>
                    <option>France</option>
                    <option>Germany</option>
                    <option>Hungary</option>
                </select>
            </div>
        </div>
        <div class="col-6">
            <div class="input-group">
                <select class="form-select">
                    <option selected>Choose...</option>
                    <option>One</option>
                    <option>Two</option>
                    <option>Three</option>
                </select>
                <button type="button" class="btn btn-secondary">Submit</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>


Creating input groups with checkbox and radio buttons in Bootstrap

Example 3

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Input Groups with Checkbox and Radio Buttons</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="m-4">
    <div class="row">
        <div class="col-6">
            <div class="input-group">
                <span class="input-group-text">
                    <input type="checkbox" class="form-check-input mt-0">
                </span>
                <input type="text" class="form-control">
            </div>
        </div>
        <div class="col-6">
            <div class="input-group">
                <span class="input-group-text">
                    <input type="radio" class="form-check-input mt-0">
                </span>
                <input type="text" class="form-control">
            </div>
        </div>
    </div>
</div>
</body>
</html>


Placing multiple inputs within an input group in Bootstrap

Example 4

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Placing Multiple Inputs within an Input Group</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="m-4">
    <div class="input-group">
        <span class="input-group-text">Your Name</span>
        <input type="text" class="form-control" placeholder="First name">
        <input type="text" class="form-control" placeholder="Last name">
    </div>
</div>
</body>
</html>

Placing multiple addons within an input group in Bootstrap

Example 5

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Placing Multiple Addons Within an Input Group</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="m-4">
    <div class="row">
        <div class="col-6">
            <div class="input-group">
                <span class="input-group-text">
                    <input type="checkbox" class="form-check-input mt-0">
                </span>
                <span class="input-group-text">$</span>
                <input type="text" class="form-control">
            </div>
        </div>
        <div class="col-6">
            <div class="input-group">
                <span class="input-group-text">$</span>
                <span class="input-group-text">0.00</span>
                <input type="text" class="form-control">
            </div>
        </div>
    </div>
</div>
</body>
</html>



Placing buttons within an input group in Bootstrap

Example 6

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Input Groups with Buttons</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="m-4">
    <div class="row">
        <div class="col-5">
            <div class="input-group">
                <input type="text" class="form-control" placeholder="Search...">
                <button type="button" class="btn btn-secondary">
                    <i class="bi-search"></i>
                </button>
            </div>
        </div>
        <div class="col-7">
            <div class="input-group">
                <input type="text" class="form-control" placeholder="Type something...">
                <button type="submit" class="btn btn-primary">Submit</button>
                <button type="reset" class="btn btn-danger">Reset</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>


Placing button dropdowns within an input group in Bootstrap

Example 7

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Input Groups with Button Dropdowns</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="m-4">
    <div class="row">
        <div class="col-6">
            <div class="input-group">
                <button type="button" class="btn btn-outline-secondary dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>
                <div class="dropdown-menu">
                    <a href="#" class="dropdown-item">Action</a>
                    <a href="#" class="dropdown-item">Another action</a>
                </div>
                <input type="text" class="form-control">
            </div>
        </div>
        <div class="col-6">
            <div class="input-group">
                <input type="text" class="form-control">
                <button type="button" class="btn btn-outline-secondary dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>
                <div class="dropdown-menu">
                    <a href="#" class="dropdown-item">Action</a>
                    <a href="#" class="dropdown-item">Another action</a>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>


Placing segmented dropdown button groups within an input group in Bootstrap

Example 8

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Input Groups with Split Dropdown Button Groups</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="m-4">
    <div class="row">
        <div class="col-6">
            <div class="input-group">
                <button type="button" class="btn btn-outline-secondary">Action</button>
                <button type="button" class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown">
                    <span class="visually-hidden">Toggle Dropdown</span>
                </button>
                <div class="dropdown-menu">
                    <a href="#" class="dropdown-item">Action</a>
                    <a href="#" class="dropdown-item">Another action</a>
                </div>
                <input type="text" class="form-control">
            </div>
        </div>
        <div class="col-6">
            <div class="input-group">
                <input type="text" class="form-control">
                <button type="button" class="btn btn-outline-secondary">Action</button>
                <button type="button" class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown">
                    <span class="visually-hidden">Toggle Dropdown</span>
                </button>
                <div class="dropdown-menu">
                    <a href="#" class="dropdown-item">Action</a>
                    <a href="#" class="dropdown-item">Another action</a>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

Height sizing of Bootstrap input groups

Example 9

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Input Group Height Sizing</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="m-4">
    <!-- Larger input group -->
    <div class="input-group input-group-lg">
        <span class="input-group-text">Large</span>
        <input type="text" class="form-control">
    </div>
            
    <!-- Default input group -->
    <div class="input-group mt-2">
        <span class="input-group-text">Default</span>
        <input type="text" class="form-control">
    </div>
            
    <!-- Smaller input group -->
    <div class="input-group input-group-sm mt-2">
        <span class="input-group-text">Small</span>
        <input type="text" class="form-control">
    </div>
</div>
</body>
</html>
----------------------------------------------------------------------
Together we are one! One we are many... Much Love from one brother to another...
Working together to achieve amazing things!
Teamwork is key.
Knowledge is Power!

4 Basic datatypes.
Strings: Which store a series of characters.
Int: Which store a full integer or number.
Float: A numeric value with a decimal.
Boolean: Only stores True or False and are very useful with if statements

----------------------------------------------------------------------
ImgBB Image upload

Who is online

Users browsing this forum: No registered users and 0 guests