Input Group
<div class="input-group"> <span class="input-group-addon"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <circle cx="11" cy="11" r="7"></circle> <path d="m20 20-3.5-3.5"></path> </svg> </span> <input class="input input-group-control" type="search" placeholder="Search" aria-label="Search" /></div><div class="input-group"> <span class="input-group-addon">…</span> <input class="input input-group-control" aria-label="Search" /></div>The group owns the border and the focus ring; the control inside gives up its own, so there is one edge rather than two boxes nested inside each other.
| Class | Part |
|---|---|
.input-group | The bordered box |
.input-group-control | The input or textarea inside it |
.input-group-addon | Anything alongside the control |
.input-group-text | Muted text inside an addon |
| Attribute | On the addon | Meaning |
|---|---|---|
(none) or data-align="inline-start" | leading edge | Before the control |
data-align="inline-end" | trailing edge | After the control |
data-align="block-start" | above | A full-width row on top |
data-align="block-end" | below | A full-width row underneath |
partialkit.dev/
<div class="input-group"> <span class="input-group-addon"><span class="input-group-text">partialkit.dev/</span></span> <input class="input input-group-control" value="docs" aria-label="Path" /></div>With a button
Section titled “With a button”<div class="input-group"> <input class="input input-group-control" placeholder="Invite by email" aria-label="Email" /> <span class="input-group-addon" data-align="inline-end"> <button class="btn btn-sm" type="button">Invite</button> </span></div>With a shortcut
Section titled “With a shortcut”
K
<div class="input-group"> <span class="input-group-addon"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <circle cx="11" cy="11" r="7"></circle> <path d="m20 20-3.5-3.5"></path> </svg> </span> <input class="input input-group-control" placeholder="Search commands" aria-label="Search commands" /> <span class="input-group-addon" data-align="inline-end"> <kbd class="kbd">K</kbd> </span></div>Textarea
Section titled “Textarea”A block-end addon puts the actions under the control, and the group grows to fit.
<div class="input-group"> <textarea class="textarea input-group-control" placeholder="Leave a comment" aria-label="Comment"></textarea> <div class="input-group-addon" data-align="block-end"> <button class="btn btn-sm" type="button">Post</button> </div></div>Set dir="rtl" on the page or on any subtree — inline-start and inline-end follow the reading
direction, which is why they are named that way rather than left and right. See
the button page for a live example.
Accessibility
Section titled “Accessibility”- The control still needs a name. The addon is not a label — an icon beside a field says
nothing. Use
<label for>, oraria-labelwhen there is no visible text. - A unit is not a label either. In
partialkit.dev/[docs], the prefix is context; the field still needs to say what it is. - The group is not focusable, only the control inside it is. The ring appears on the group
because that is the visible box, but focus never lands on a
<div>.