Forms
Input group
Text, buttons, checks and details-based dropdowns on either side of an input, with cream-300 addons.
How it works in this theme
.input-group is a flex row. Adjacent children overlap by one border width and lose their inner
corners, so a field, its addons and its buttons read as one control. The theme changes:
- Addon (
.input-group-text) background and border:cream-300(#d9cdb0). - Corners: 2 px, matching inputs and buttons.
- Dropdown buttons: a
<details class="dropdown">instead of a JavaScript toggle. See below.
Basic example
Place one add-on or button on either side of an input. You may also place one on both sides of an input.
Remember to place <label>s outside the input group.
HTML
<div class="input-group mb-4">
<span class="input-group-text" id="input-group-basic-addon1">@</span>
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="input-group-basic-addon1" />
</div>
<div class="input-group mb-4">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="input-group-basic-addon2" />
<span class="input-group-text" id="input-group-basic-addon2">@example.com</span>
</div>
<label for="input-group-basic-url" class="form-label">Your vanity URL</label>
<div class="input-group mb-4">
<span class="input-group-text" id="input-group-basic-addon3">https://ropebreakdotnet.example/</span>
<input type="text" class="form-control" id="input-group-basic-url" aria-describedby="input-group-basic-addon3" />
</div>
<div class="input-group mb-4">
<span class="input-group-text">$</span>
<input type="text" class="form-control" aria-label="Amount (to the nearest dollar)" />
<span class="input-group-text">.00</span>
</div>
<div class="input-group mb-4">
<input type="text" class="form-control" placeholder="Username" aria-label="Username" />
<span class="input-group-text">@</span>
<input type="text" class="form-control" placeholder="Server" aria-label="Server" />
</div>
<div class="input-group">
<span class="input-group-text">Promo</span>
<textarea class="form-control" aria-label="Promo text"></textarea>
</div>Wrapping
Input groups wrap by default via flex-wrap: wrap in order to accommodate custom form field
validation within an input group. You may disable this with .flex-nowrap.
HTML
<div class="input-group flex-nowrap">
<span class="input-group-text" id="input-group-nowrap-addon">@</span>
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="input-group-nowrap-addon" />
</div>Sizing
Add the relative form sizing classes to the .input-group itself and contents will
automatically resize — no need for repeating the form control size classes on each element.
Sizing on the individual input group elements isn't supported.
HTML
<div class="input-group input-group-sm mb-4">
<span class="input-group-text" id="input-group-sizing-sm">Small</span>
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="input-group-sizing-sm" />
</div>
<div class="input-group mb-4">
<span class="input-group-text" id="input-group-sizing-default">Default</span>
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="input-group-sizing-default" />
</div>
<div class="input-group input-group-lg">
<span class="input-group-text" id="input-group-sizing-lg">Large</span>
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="input-group-sizing-lg" />
</div>Checkboxes and radios
Place any checkbox or radio option within an input group's addon instead of text. We recommend adding
.mt-0 to the .form-check-input when there's no visible text next to the input.
HTML
<div class="input-group mb-4">
<div class="input-group-text">
<input class="form-check-input mt-0" type="checkbox" value="" aria-label="Checkbox for following text input" />
</div>
<input type="text" class="form-control" aria-label="Text input with checkbox" />
</div>
<div class="input-group">
<div class="input-group-text">
<input class="form-check-input mt-0" type="radio" value="" aria-label="Radio button for following text input" />
</div>
<input type="text" class="form-control" aria-label="Text input with radio button" />
</div>Multiple inputs
While multiple <input>s are supported visually, validation styles are only available for input groups with a single <input>.
HTML
<div class="input-group">
<span class="input-group-text">First and last name</span>
<input type="text" aria-label="First name" class="form-control" />
<input type="text" aria-label="Last name" class="form-control" />
</div>Multiple addons
Multiple add-ons are supported and can be mixed with checkbox and radio input versions.
HTML
<div class="input-group mb-4">
<span class="input-group-text">$</span>
<span class="input-group-text">0.00</span>
<input type="text" class="form-control" aria-label="Dollar amount (with dot and two decimal places)" />
</div>
<div class="input-group">
<input type="text" class="form-control" aria-label="Dollar amount (with dot and two decimal places)" />
<span class="input-group-text">$</span>
<span class="input-group-text">0.00</span>
</div>Button addons
HTML
<div class="input-group mb-4">
<button class="btn btn-outline-secondary" type="button" id="input-group-button-addon1">Button</button>
<input type="text" class="form-control" placeholder="" aria-label="Example text with button addon" aria-describedby="input-group-button-addon1" />
</div>
<div class="input-group mb-4">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="input-group-button-addon2" />
<button class="btn btn-outline-secondary" type="button" id="input-group-button-addon2">Button</button>
</div>
<div class="input-group mb-4">
<button class="btn btn-outline-secondary" type="button">Button</button>
<button class="btn btn-outline-secondary" type="button">Button</button>
<input type="text" class="form-control" placeholder="" aria-label="Example text with two button addons" />
</div>
<div class="input-group">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username with two button addons" />
<button class="btn btn-outline-secondary" type="button">Button</button>
<button class="btn btn-outline-secondary" type="button">Button</button>
</div>Buttons with dropdowns
Stock Bootstrap toggles the menu with JavaScript. Here the dropdown is a
<details class="dropdown"> whose <summary> carries the button classes.
Two details matter inside an input group:
- Add
.d-flexto the<details>. It is a flex item of the group and stretches to the row height;.d-flexmakes the summary stretch with it, which matters for a split toggle that has no text. - The menu is positioned under the
<details>, so a trailing dropdown should use.dropdown-menu-endto keep it inside the group.
Dropdown
Dropdown
Dropdown
Dropdown
HTML
<div class="input-group mb-4">
<details class="dropdown d-flex">
<summary class="btn btn-outline-secondary dropdown-toggle">Dropdown</summary>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#!">Action</a></li>
<li><a class="dropdown-item" href="#!">Another action</a></li>
<li><a class="dropdown-item" href="#!">Something else here</a></li>
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" href="#!">Separated link</a></li>
</ul>
</details>
<input type="text" class="form-control" aria-label="Text input with dropdown button" />
</div>
<div class="input-group mb-4">
<input type="text" class="form-control" aria-label="Text input with dropdown button" />
<details class="dropdown d-flex">
<summary class="btn btn-outline-secondary dropdown-toggle">Dropdown</summary>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" href="#!">Action</a></li>
<li><a class="dropdown-item" href="#!">Another action</a></li>
<li><a class="dropdown-item" href="#!">Something else here</a></li>
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" href="#!">Separated link</a></li>
</ul>
</details>
</div>
<div class="input-group">
<details class="dropdown d-flex">
<summary class="btn btn-outline-secondary dropdown-toggle">Dropdown</summary>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#!">Action before</a></li>
<li><a class="dropdown-item" href="#!">Another action before</a></li>
<li><a class="dropdown-item" href="#!">Something else here</a></li>
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" href="#!">Separated link</a></li>
</ul>
</details>
<input type="text" class="form-control" aria-label="Text input with 2 dropdown buttons" />
<details class="dropdown d-flex">
<summary class="btn btn-outline-secondary dropdown-toggle">Dropdown</summary>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" href="#!">Action</a></li>
<li><a class="dropdown-item" href="#!">Another action</a></li>
<li><a class="dropdown-item" href="#!">Something else here</a></li>
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" href="#!">Separated link</a></li>
</ul>
</details>
</div><details> menu does not close when you click elsewhere. If you need light-dismiss, use
the popover dropdown variant documented in Dropdowns:
a plain <button class="btn … dropdown-toggle" popovertarget="…"> as a direct child of the
group, with the <ul class="dropdown-menu" popover> anywhere in the document.Segmented buttons
Pair an ordinary button with a .dropdown-toggle-split summary. The split toggle contains only
a visually-hidden label, which is why .d-flex on the <details> is required to
give it full height.
Toggle Dropdown
Toggle Dropdown
HTML
<div class="input-group mb-4">
<button type="button" class="btn btn-outline-secondary">Action</button>
<details class="dropdown d-flex">
<summary class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split"><span class="visually-hidden">Toggle Dropdown</span></summary>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#!">Action</a></li>
<li><a class="dropdown-item" href="#!">Another action</a></li>
<li><a class="dropdown-item" href="#!">Something else here</a></li>
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" href="#!">Separated link</a></li>
</ul>
</details>
<input type="text" class="form-control" aria-label="Text input with segmented dropdown button" />
</div>
<div class="input-group">
<input type="text" class="form-control" aria-label="Text input with segmented dropdown button" />
<button type="button" class="btn btn-outline-secondary">Action</button>
<details class="dropdown d-flex">
<summary class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split"><span class="visually-hidden">Toggle Dropdown</span></summary>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" href="#!">Action</a></li>
<li><a class="dropdown-item" href="#!">Another action</a></li>
<li><a class="dropdown-item" href="#!">Something else here</a></li>
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" href="#!">Separated link</a></li>
</ul>
</details>
</div>Custom forms
Input groups include support for custom selects and custom file inputs. Browser default versions of these are not supported.
Custom select
HTML
<div class="input-group mb-4">
<label class="input-group-text" for="input-group-select-1">Options</label>
<select class="form-select" id="input-group-select-1">
<option selected>Choose…</option>
<option value="1">Singles</option>
<option value="2">Tag team</option>
<option value="3">Steel cage</option>
</select>
</div>
<div class="input-group mb-4">
<select class="form-select" id="input-group-select-2">
<option selected>Choose…</option>
<option value="1">Singles</option>
<option value="2">Tag team</option>
<option value="3">Steel cage</option>
</select>
<label class="input-group-text" for="input-group-select-2">Options</label>
</div>
<div class="input-group mb-4">
<button class="btn btn-outline-secondary" type="button">Button</button>
<label class="visually-hidden" for="input-group-select-3">Match type</label>
<select class="form-select" id="input-group-select-3" aria-label="Example select with button addon">
<option selected>Choose…</option>
<option value="1">Singles</option>
<option value="2">Tag team</option>
<option value="3">Steel cage</option>
</select>
</div>
<div class="input-group">
<label class="visually-hidden" for="input-group-select-4">Match type</label>
<select class="form-select" id="input-group-select-4" aria-label="Example select with button addon">
<option selected>Choose…</option>
<option value="1">Singles</option>
<option value="2">Tag team</option>
<option value="3">Steel cage</option>
</select>
<button class="btn btn-outline-secondary" type="button">Button</button>
</div>Custom file input
HTML
<div class="input-group mb-4">
<label class="input-group-text" for="input-group-file-1">Upload</label>
<input type="file" class="form-control" id="input-group-file-1" />
</div>
<div class="input-group mb-4">
<input type="file" class="form-control" id="input-group-file-2" />
<label class="input-group-text" for="input-group-file-2">Upload</label>
</div>
<div class="input-group mb-4">
<button class="btn btn-outline-secondary" type="button" id="input-group-file-addon3">Button</button>
<label class="visually-hidden" for="input-group-file-3">Upload</label>
<input type="file" class="form-control" id="input-group-file-3" aria-describedby="input-group-file-addon3" aria-label="Upload" />
</div>
<div class="input-group">
<label class="visually-hidden" for="input-group-file-4">Upload</label>
<input type="file" class="form-control" id="input-group-file-4" aria-describedby="input-group-file-addon4" aria-label="Upload" />
<button class="btn btn-outline-secondary" type="button" id="input-group-file-addon4">Button</button>
</div>Sass variables
From scss/_variables.scss:
$input-group-addon-bg: $rb-cream-300;
Inherited from Bootstrap's defaults:
$input-group-addon-padding-y: $input-padding-y;
$input-group-addon-padding-x: $input-padding-x;
$input-group-addon-font-weight: $input-font-weight;
$input-group-addon-color: $input-color; // var(--bs-body-color)
$input-group-addon-border-color: $input-border-color; // cream-300