Input groups
Input groups attach text, icons or buttons to the sides of an input.
In this page:
Syntax
<div class="input-group">
<span class="input-group-text">@</span>
<input type="text" class="form-control">
</div>
Input groups
Wrap an input in .input-group and add .input-group-text or button elements before or after it. Groups can hold several inputs and support size classes like .input-group-lg. Keep a label associated with the input for accessibility.
Note:
Put labels outside the input group, not inside it.
Example: Input groups
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
<label for="user" class="form-label">Username</label>
<div class="input-group mb-3"><span class="input-group-text">@</span><input id="user" class="form-control" placeholder="username"></div>
<div class="input-group"><input class="form-control" placeholder="Search" aria-label="Search"><button class="btn btn-outline-secondary">Go</button></div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
- Forgetting the input-group wrapper
- Placing text outside the group
- Missing accessible labels
Chapter Summary
- .input-group wraps controls
- input-group-text adds addons
- Buttons can be attached
- Size classes apply to the group
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: