2014-03-17 03:03:53 +01:00
< div class = "bs-docs-section" >
< h1 id = "input-groups" class = "page-header" > Input groups< / h1 >
2014-08-29 04:55:23 +02:00
< p class = "lead" > Extend form controls by adding text or buttons before, after, or on both sides of any text-based < code > < input> < / code > . Use < code > .input-group< / code > with an < code > .input-group-addon< / code > to prepend or append elements to a single < code > .form-control< / code > .< / p >
2014-03-17 03:03:53 +01:00
2014-11-12 05:23:49 +01:00
< div class = "bs-callout bs-callout-danger" id = "callout-inputgroup-text-input-only" >
2014-08-29 04:55:23 +02:00
< h4 > Textual < code > < input> < / code > s only< / h4 >
2014-03-17 03:03:53 +01:00
< p > Avoid using < code > < select> < / code > elements here as they cannot be fully styled in WebKit browsers.< / p >
2014-08-29 04:55:23 +02:00
< p > Avoid using < code > < textarea> < / code > elements here as their < code > rows< / code > attribute will not be respected in some cases.< / p >
2014-03-17 03:03:53 +01:00
< / div >
2014-11-12 05:23:49 +01:00
< div class = "bs-callout bs-callout-warning" id = "callout-inputgroup-container-body" >
2014-03-17 03:03:53 +01:00
< h4 > Tooltips & popovers in input groups require special setting< / h4 >
< p > When using tooltips or popovers on elements within an < code > .input-group< / code > , you'll have to specify the option < code > container: 'body'< / code > to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip or popover is triggered).< / p >
< / div >
2014-11-12 05:23:49 +01:00
< div class = "bs-callout bs-callout-warning" id = "callout-inputgroup-dont-mix" >
2014-03-17 03:03:53 +01:00
< h4 > Don't mix with other components< / h4 >
< p > Do not mix form groups or grid column classes directly with input groups. Instead, nest the input group inside of the form group or grid-related element.< / p >
< / div >
2014-12-08 15:03:04 +01:00
< div class = "bs-callout bs-callout-warning" id = "callout-inputgroup-form-labels" >
< h4 > Always add labels< / h4 >
< p > 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.< / p >
< p > The exact technique to be used (< code > < label> < / code > elements hidden using the < code > .sr-only< / code > class, or use of the < code > aria-label< / code > , < code > aria-labelledby< / code > , < code > aria-describedby< / code > , < code > title< / code > or < code > placeholder< / code > 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.< / p >
< / div >
2014-03-17 03:03:53 +01:00
< h2 id = "input-groups-basic" > Basic example< / h2 >
< p > Place one add-on or button on either side of an input. You may also place one on both sides of an input.< / p >
< p > < strong class = "text-danger" > We do not support multiple add-ons on a single side.< / strong > < / p >
< p > < strong class = "text-danger" > We do not support multiple form-controls in a single input group.< / strong > < / p >
2014-11-25 02:09:32 +01:00
< form class = "bs-example bs-example-form" data-example-id = "simple-input-groups" >
2014-03-17 03:03:53 +01:00
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< span class = "input-group-addon" id = "basic-addon1" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "basic-addon1" >
2014-03-17 03:03:53 +01:00
< / div >
< br >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" placeholder = "Recipient's username" aria-describedby = "basic-addon2" >
< span class = "input-group-addon" id = "basic-addon2" > @example.com< / span >
2014-03-17 03:03:53 +01:00
< / div >
< br >
< div class = "input-group" >
< span class = "input-group-addon" > $< / span >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "Amount (to the nearest dollar)" >
2014-03-17 03:03:53 +01:00
< span class = "input-group-addon" > .00< / span >
< / div >
< / form >
{% highlight html %}
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< span class = "input-group-addon" id = "basic-addon1" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "basic-addon1" >
2014-03-17 03:03:53 +01:00
< / div >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" placeholder = "Recipient's username" aria-describedby = "basic-addon2" >
< span class = "input-group-addon" id = "basic-addon2" > @example.com< / span >
2014-03-17 03:03:53 +01:00
< / div >
< div class = "input-group" >
< span class = "input-group-addon" > $< / span >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "Amount (to the nearest dollar)" >
2014-03-17 03:03:53 +01:00
< span class = "input-group-addon" > .00< / span >
< / div >
{% endhighlight %}
< h2 id = "input-groups-sizing" > Sizing< / h2 >
< p > Add the relative form sizing classes to the < code > .input-group< / code > itself and contents within will automatically resize—no need for repeating the form control size classes on each element.< / p >
2014-11-25 02:09:32 +01:00
< form class = "bs-example bs-example-form" data-example-id = "input-group-sizing" >
2014-03-17 03:03:53 +01:00
< div class = "input-group input-group-lg" >
2014-12-08 15:03:04 +01:00
< span class = "input-group-addon" id = "sizing-addon1" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "sizing-addon1" >
2014-03-17 03:03:53 +01:00
< / div >
< br >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< span class = "input-group-addon" id = "sizing-addon2" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "sizing-addon2" >
2014-03-17 03:03:53 +01:00
< / div >
< br >
< div class = "input-group input-group-sm" >
2014-12-08 15:03:04 +01:00
< span class = "input-group-addon" id = "sizing-addon3" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "sizing-addon3" >
2014-03-17 03:03:53 +01:00
< / div >
< / form >
{% highlight html %}
< div class = "input-group input-group-lg" >
2014-12-08 15:03:04 +01:00
< span class = "input-group-addon" id = "sizing-addon1" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "sizing-addon1" >
2014-03-17 03:03:53 +01:00
< / div >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< span class = "input-group-addon" id = "sizing-addon2" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "sizing-addon2" >
2014-03-17 03:03:53 +01:00
< / div >
< div class = "input-group input-group-sm" >
2014-12-08 15:03:04 +01:00
< span class = "input-group-addon" id = "sizing-addon3" > @< / span >
< input type = "text" class = "form-control" placeholder = "Username" aria-describedby = "sizing-addon3" >
2014-03-17 03:03:53 +01:00
< / div >
{% endhighlight %}
< h2 id = "input-groups-checkboxes-radios" > Checkboxes and radio addons< / h2 >
< p > Place any checkbox or radio option within an input group's addon instead of text.< / p >
2014-11-25 02:09:32 +01:00
< form class = "bs-example bs-example-form" data-example-id = "input-group-with-checkbox-radio" >
2014-03-17 03:03:53 +01:00
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< span class = "input-group-addon" >
2014-12-08 15:03:04 +01:00
< input type = "checkbox" aria-label = "Checkbox for following text input" >
2014-03-17 03:03:53 +01:00
< / span >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "Text input with checkbox" >
2014-03-17 03:03:53 +01:00
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< div class = "col-lg-6" >
< div class = "input-group" >
< span class = "input-group-addon" >
2014-12-08 15:03:04 +01:00
< input type = "radio" aria-label = "Radio button for following text input" >
2014-03-17 03:03:53 +01:00
< / span >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "Text input with radio button" >
2014-03-17 03:03:53 +01:00
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< / div > <!-- /.row -->
< / form >
{% highlight html %}
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< span class = "input-group-addon" >
2014-12-08 15:03:04 +01:00
< input type = "checkbox" aria-label = "..." >
2014-03-17 03:03:53 +01:00
< / span >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "..." >
2014-03-17 03:03:53 +01:00
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< div class = "col-lg-6" >
< div class = "input-group" >
< span class = "input-group-addon" >
2014-12-08 15:03:04 +01:00
< input type = "radio" aria-label = "..." >
2014-03-17 03:03:53 +01:00
< / span >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "..." >
2014-03-17 03:03:53 +01:00
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< / div > <!-- /.row -->
{% endhighlight %}
< h2 id = "input-groups-buttons" > Button addons< / h2 >
< p > Buttons in input groups are a bit different and require one extra level of nesting. Instead of < code > .input-group-addon< / code > , you'll need to use < code > .input-group-btn< / code > to wrap the buttons. This is required due to default browser styles that cannot be overridden.< / p >
2014-11-25 02:09:32 +01:00
< form class = "bs-example bs-example-form" data-example-id = "input-group-with-button" >
2014-03-17 03:03:53 +01:00
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< span class = "input-group-btn" >
< button class = "btn btn-default" type = "button" > Go!< / button >
< / span >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" placeholder = "Search for..." >
2014-03-17 03:03:53 +01:00
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< div class = "col-lg-6" >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" placeholder = "Search for..." >
2014-03-17 03:03:53 +01:00
< span class = "input-group-btn" >
< button class = "btn btn-default" type = "button" > Go!< / button >
< / span >
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< / div > <!-- /.row -->
< / form >
{% highlight html %}
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< span class = "input-group-btn" >
< button class = "btn btn-default" type = "button" > Go!< / button >
< / span >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" placeholder = "Search for..." >
2014-03-17 03:03:53 +01:00
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< div class = "col-lg-6" >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" placeholder = "Search for..." >
2014-03-17 03:03:53 +01:00
< span class = "input-group-btn" >
< button class = "btn btn-default" type = "button" > Go!< / button >
< / span >
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< / div > <!-- /.row -->
{% endhighlight %}
< h2 id = "input-groups-buttons-dropdowns" > Buttons with dropdowns< / h2 >
< p > < / p >
2014-11-25 02:09:32 +01:00
< form class = "bs-example bs-example-form" data-example-id = "input-group-dropdowns" >
2014-03-17 03:03:53 +01:00
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< div class = "input-group-btn" >
2015-06-02 10:41:40 +02:00
< button type = "button" class = "btn btn-default dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" > Action < span class = "caret" > < / span > < / button >
< ul class = "dropdown-menu" >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
2015-05-30 00:48:35 +02:00
< li role = "separator" class = "divider" > < / li >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
< / div > <!-- /btn - group -->
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "Text input with dropdown button" >
2014-03-17 03:03:53 +01:00
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< div class = "col-lg-6" >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "Text input with dropdown button" >
2014-03-17 03:03:53 +01:00
< div class = "input-group-btn" >
2015-06-02 10:41:40 +02:00
< button type = "button" class = "btn btn-default dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" > Action < span class = "caret" > < / span > < / button >
< ul class = "dropdown-menu dropdown-menu-right" >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
2015-05-30 00:48:35 +02:00
< li role = "separator" class = "divider" > < / li >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
< / div > <!-- /btn - group -->
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< / div > <!-- /.row -->
< / form >
{% highlight html %}
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< div class = "input-group-btn" >
2015-06-02 10:41:40 +02:00
< button type = "button" class = "btn btn-default dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" > Action < span class = "caret" > < / span > < / button >
< ul class = "dropdown-menu" >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
2015-05-30 00:48:35 +02:00
< li role = "separator" class = "divider" > < / li >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
< / div > <!-- /btn - group -->
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "..." >
2014-03-17 03:03:53 +01:00
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< div class = "col-lg-6" >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "..." >
2014-03-17 03:03:53 +01:00
< div class = "input-group-btn" >
2015-06-02 10:41:40 +02:00
< button type = "button" class = "btn btn-default dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" > Action < span class = "caret" > < / span > < / button >
< ul class = "dropdown-menu dropdown-menu-right" >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
2015-05-30 00:48:35 +02:00
< li role = "separator" class = "divider" > < / li >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
< / div > <!-- /btn - group -->
< / div > <!-- /input - group -->
< / div > <!-- /.col - lg - 6 -->
< / div > <!-- /.row -->
{% endhighlight %}
< h2 id = "input-groups-buttons-segmented" > Segmented buttons< / h2 >
2014-11-25 02:09:32 +01:00
< form class = "bs-example bs-example-form" data-example-id = "input-group-segmented-buttons" >
2014-03-17 03:03:53 +01:00
< div class = "row" >
< div class = "col-lg-6" >
< div class = "input-group" >
< div class = "input-group-btn" >
2014-12-08 16:25:02 +01:00
< button type = "button" class = "btn btn-default" > Action< / button >
2015-06-02 10:41:40 +02:00
< button type = "button" class = "btn btn-default dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" >
2014-03-17 03:03:53 +01:00
< span class = "caret" > < / span >
< span class = "sr-only" > Toggle Dropdown< / span >
< / button >
2015-06-02 10:41:40 +02:00
< ul class = "dropdown-menu" >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
2015-05-30 00:48:35 +02:00
< li role = "separator" class = "divider" > < / li >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
< / div >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "Text input with segmented button dropdown" >
2014-03-17 03:03:53 +01:00
< / div > <!-- /.input - group -->
< / div > <!-- /.col - lg - 6 -->
< div class = "col-lg-6" >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "Text input with segmented button dropdown" >
2014-03-17 03:03:53 +01:00
< div class = "input-group-btn" >
2014-12-08 16:25:02 +01:00
< button type = "button" class = "btn btn-default" > Action< / button >
2015-06-02 10:41:40 +02:00
< button type = "button" class = "btn btn-default dropdown-toggle" data-toggle = "dropdown" aria-haspopup = "true" aria-expanded = "false" >
2014-03-17 03:03:53 +01:00
< span class = "caret" > < / span >
< span class = "sr-only" > Toggle Dropdown< / span >
< / button >
2015-06-02 10:41:40 +02:00
< ul class = "dropdown-menu dropdown-menu-right" >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Action< / a > < / li >
< li > < a href = "#" > Another action< / a > < / li >
< li > < a href = "#" > Something else here< / a > < / li >
2015-05-30 00:48:35 +02:00
< li role = "separator" class = "divider" > < / li >
2014-03-17 03:03:53 +01:00
< li > < a href = "#" > Separated link< / a > < / li >
< / ul >
< / div >
< / div > <!-- /.input - group -->
< / div > <!-- /.col - lg - 6 -->
< / div > <!-- /.row -->
< / form >
{% highlight html %}
< div class = "input-group" >
< div class = "input-group-btn" >
<!-- Button and dropdown menu -->
< / div >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "..." >
2014-03-17 03:03:53 +01:00
< / div >
< div class = "input-group" >
2014-12-08 15:03:04 +01:00
< input type = "text" class = "form-control" aria-label = "..." >
2014-03-17 03:03:53 +01:00
< div class = "input-group-btn" >
<!-- Button and dropdown menu -->
< / div >
< / div >
{% endhighlight %}
< / div >