2014-07-13 03:59:31 -04:00
---
layout: page
title: Input group
---
2015-03-09 10:46:32 -04:00
Easily extend form controls by adding text, buttons, or button groups on either side of textual `<input>` s.
2014-03-16 22:03:53 -04:00
2014-07-13 04:12:02 -04:00
## Basic example
2014-03-16 22:03:53 -04:00
2015-03-09 10:46:32 -04:00
Place one add-on or button on either side of an input. You may also place one on both sides of an input. **We do not support multiple add-ons on a single side, nor multiple form-controls in a single input group.**
2014-07-13 04:12:02 -04:00
{% example html %}
2014-03-16 22:03:53 -04:00
< div class = "input-group" >
2015-01-03 23:08:58 -05:00
< span class = "input-group-addon" id = "basic-addon1" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "basic-addon1" >
2014-03-16 22:03:53 -04:00
< / div >
2014-07-13 04:12:02 -04:00
< br >
2014-03-16 22:03:53 -04:00
< div class = "input-group" >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" placeholder = "Recipient's username" aria-describedby = "basic-addon2" >
< span class = "input-group-addon" id = "basic-addon2" > .00< / span >
2014-03-16 22:03:53 -04:00
< / div >
2014-07-13 04:12:02 -04:00
< br >
2014-03-16 22:03:53 -04:00
< div class = "input-group" >
< span class = "input-group-addon" > $< / span >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" aria-label = "Amount (to the nearest dollar)" >
2014-03-16 22:03:53 -04:00
< span class = "input-group-addon" > .00< / span >
< / div >
2014-07-13 04:12:02 -04:00
{% endexample %}
2014-03-16 22:03:53 -04:00
2014-07-13 04:12:02 -04:00
## Sizing
Add the relative form sizing classes to the `.input-group` itself and contents within will automatically resize—no need for repeating the form control size classes on each element.
{% example html %}
2014-03-16 22:03:53 -04:00
< div class = "input-group input-group-lg" >
2015-01-03 23:08:58 -05:00
< span class = "input-group-addon" id = "sizing-addon1" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "sizing-addon1" >
2014-03-16 22:03:53 -04:00
< / div >
2014-07-13 04:12:02 -04:00
< br >
2014-03-16 22:03:53 -04:00
< div class = "input-group" >
2015-01-03 23:08:58 -05:00
< span class = "input-group-addon" id = "sizing-addon2" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "sizing-addon2" >
2014-03-16 22:03:53 -04:00
< / div >
2014-07-13 04:12:02 -04:00
< br >
2014-03-16 22:03:53 -04:00
< div class = "input-group input-group-sm" >
2015-01-03 23:08:58 -05:00
< span class = "input-group-addon" id = "sizing-addon3" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "sizing-addon3" >
2014-03-16 22:03:53 -04:00
< / div >
2014-07-13 04:12:02 -04:00
{% endexample %}
## Checkboxes and radio addons
2014-03-16 22:03:53 -04:00
2014-07-13 04:12:02 -04:00
Place any checkbox or radio option within an input group's addon instead of text.
2014-03-16 22:03:53 -04:00
2014-07-13 04:12:02 -04:00
{% example html %}
2014-03-16 22:03:53 -04:00
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< span class = "input-group-addon" >
2015-01-03 23:08:58 -05:00
< input type = "checkbox" aria-label = "Checkbox for following text input" >
2014-03-16 22:03:53 -04:00
< / span >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" aria-label = "Text input with checkbox" >
2014-07-13 04:12:02 -04:00
< / div >
< / div >
2014-03-16 22:03:53 -04:00
< div class = "col-lg-6" >
< div class = "input-group" >
< span class = "input-group-addon" >
2015-01-03 23:08:58 -05:00
< input type = "radio" aria-label = "Radio button for following text input" >
2014-03-16 22:03:53 -04:00
< / span >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" aria-label = "Text input with radio button" >
2014-07-13 04:12:02 -04:00
< / div >
< / div >
< / div >
{% endexample %}
2014-03-16 22:03:53 -04:00
2014-07-13 04:12:02 -04:00
## Button addons
2014-03-16 22:03:53 -04:00
2014-07-13 04:12:02 -04:00
Buttons in input groups are a bit different and require one extra level of nesting. Instead of `.input-group-addon` , you'll need to use `.input-group-btn` to wrap the buttons. This is required due to default browser styles that cannot be overridden.
{% example html %}
2014-03-16 22:03:53 -04:00
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< span class = "input-group-btn" >
2014-07-08 20:14:14 -04:00
< button class = "btn btn-secondary" type = "button" > Go!< / button >
2014-03-16 22:03:53 -04:00
< / span >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" placeholder = "Search for..." >
2014-07-13 04:12:02 -04:00
< / div >
< / div >
2014-03-16 22:03:53 -04:00
< div class = "col-lg-6" >
< div class = "input-group" >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" placeholder = "Search for..." >
2014-03-16 22:03:53 -04:00
< span class = "input-group-btn" >
2014-07-08 20:14:14 -04:00
< button class = "btn btn-secondary" type = "button" > Go!< / button >
2014-03-16 22:03:53 -04:00
< / span >
2014-07-13 04:12:02 -04:00
< / div >
< / div >
< / div >
{% endexample %}
2014-03-16 22:03:53 -04:00
2014-07-13 04:12:02 -04:00
## Buttons with dropdowns
{% example html %}
2014-03-16 22:03:53 -04:00
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< div class = "input-group-btn" >
2014-11-30 23:17:45 -05:00
< button type = "button" class = "btn btn-secondary dropdown-toggle" data-toggle = "dropdown" aria-expanded = "false" > Action< / button >
2014-05-28 19:52:36 -04:00
< ul class = "dropdown-menu" role = "menu" >
2014-03-16 22:03:53 -04:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
< li class = "divider" > < / li >
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
2014-07-13 04:12:02 -04:00
< / div >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" aria-label = "Text input with dropdown button" >
2014-07-13 04:12:02 -04:00
< / div >
< / div >
2014-03-16 22:03:53 -04:00
< div class = "col-lg-6" >
< div class = "input-group" >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" aria-label = "Text input with dropdown button" >
2014-03-16 22:03:53 -04:00
< div class = "input-group-btn" >
2014-11-30 23:17:45 -05:00
< button type = "button" class = "btn btn-secondary dropdown-toggle" data-toggle = "dropdown" aria-expanded = "false" > Action< / button >
2014-05-28 19:52:36 -04:00
< ul class = "dropdown-menu dropdown-menu-right" role = "menu" >
2014-03-16 22:03:53 -04:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
< li class = "divider" > < / li >
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
2014-07-13 04:12:02 -04:00
< / div >
< / div >
2014-03-16 22:03:53 -04:00
< / div >
< / div >
2014-07-13 04:12:02 -04:00
{% endexample %}
2014-03-16 22:03:53 -04:00
2014-07-13 04:12:02 -04:00
## Segmented buttons
{% example html %}
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< div class = "input-group-btn" >
2015-01-03 23:08:58 -05:00
< button type = "button" class = "btn btn-secondary" > Action< / button >
< button type = "button" class = "btn btn-secondary dropdown-toggle" data-toggle = "dropdown" aria-expanded = "false" >
2014-07-13 04:12:02 -04:00
< span class = "sr-only" > Toggle Dropdown< / span >
< / button >
< ul class = "dropdown-menu" role = "menu" >
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
< li class = "divider" > < / li >
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
< / div >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" aria-label = "Text input with segmented button dropdown" >
2014-07-13 04:12:02 -04:00
< / div >
< / div >
< div class = "col-lg-6" >
< div class = "input-group" >
2015-01-03 23:08:58 -05:00
< input type = "text" class = "form-control" aria-label = "Text input with segmented button dropdown" >
2014-07-13 04:12:02 -04:00
< div class = "input-group-btn" >
2015-01-03 23:08:58 -05:00
< button type = "button" class = "btn btn-secondary" > Action< / button >
< button type = "button" class = "btn btn-secondary dropdown-toggle" data-toggle = "dropdown" aria-expanded = "false" >
2014-07-13 04:12:02 -04:00
< span class = "sr-only" > Toggle Dropdown< / span >
< / button >
< ul class = "dropdown-menu dropdown-menu-right" role = "menu" >
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
< li class = "divider" > < / li >
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
< / div >
< / div >
2014-03-16 22:03:53 -04:00
< / div >
< / div >
2014-07-13 04:12:02 -04:00
{% endexample %}
2015-03-09 10:48:51 -04:00
## Accessibility
Screen readers will have trouble with your forms if you don't include a label for every input. For these input groups, ensure that any additional label or functionality is conveyed to assistive technologies.
The exact technique to be used (`< label > ` elements hidden using the `.sr-only` class, or use of the `aria-label` , `aria-labelledby` , `aria-describedby` , `title` or `placeholder` attribute) and what additional information will need to be conveyed will vary depending on the exact type of interface widget you're implementing. The examples in this section provide a few suggested, case-specific approaches.