2014-07-13 03:59:31 -04:00
---
2015-08-15 01:45:55 -04:00
layout: docs
2014-07-13 03:59:31 -04:00
title: Input group
2015-08-05 20:47:45 -04:00
group: components
2014-07-13 03:59:31 -04:00
---
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
2015-05-29 04:58:52 -04:00
## Contents
* Will be replaced with the ToC, excluding the "Contents" header
{:toc}
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 >
2015-08-05 01:29:45 -04:00
< label for = "basic-url" > Your vanity URL< / label >
< div class = "input-group" >
< span class = "input-group-addon" id = "basic-addon3" > https://example.com/users/< / span >
< input type = "text" class = "form-control" id = "basic-url" aria-describedby = "basic-addon3" >
< / div >
< 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" >
2015-06-19 02:56:43 -04:00
< button type = "button" class = "btn btn-secondary dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" >
Action
< / button >
< ul class = "dropdown-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 >
2015-06-19 02:56:43 -04:00
< li role = "separator" class = "divider" > < / li >
2014-03-16 22:03:53 -04:00
< 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" >
2015-06-19 02:56:43 -04:00
< button type = "button" class = "btn btn-secondary dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" >
Action
< / button >
< ul class = "dropdown-menu dropdown-menu-right" >
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 >
2015-06-19 02:56:43 -04:00
< li role = "separator" class = "divider" > < / li >
2014-03-16 22:03:53 -04:00
< 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 >
2015-06-19 02:56:43 -04:00
< button type = "button" class = "btn btn-secondary dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" >
2014-07-13 04:12:02 -04:00
< span class = "sr-only" > Toggle Dropdown< / span >
< / button >
2015-06-19 02:56:43 -04:00
< ul class = "dropdown-menu" >
2014-07-13 04:12:02 -04:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
2015-06-19 02:56:43 -04:00
< li role = "separator" class = "divider" > < / li >
2014-07-13 04:12:02 -04:00
< 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 >
2015-06-19 02:56:43 -04:00
< button type = "button" class = "btn btn-secondary dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" >
2014-07-13 04:12:02 -04:00
< span class = "sr-only" > Toggle Dropdown< / span >
< / button >
2015-06-19 02:56:43 -04:00
< ul class = "dropdown-menu dropdown-menu-right" >
2014-07-13 04:12:02 -04:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
2015-06-19 02:56:43 -04:00
< li role = "separator" class = "divider" > < / li >
2014-07-13 04:12:02 -04:00
< 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.