YouTip LogoYouTip

Bootstrap Input Groups

This chapter will explain another feature supported by Bootstrap: input groups. Input groups extend from (#). Using input groups, you can easily prepend and append text or buttons to text-based inputs. By adding prefix and suffix content to input fields, you can add common elements to user input. For example, you can add a dollar sign, an @ before a Twitter username, or other common elements required by an application interface. The steps to add prefix or suffix elements to a **.form-control** are as follows: * Place the prefix or suffix element inside a `
` with the class **.input-group**. * Then, within the same `
`, place the additional content inside a `` with the class **.input-group-addon**. * Place this `` either before or after the `` element. > !(#)To maintain cross-browser compatibility, avoid using `` elements, as they do not render fully in WebKit browsers. Also, do not apply input group classes directly to form groups; input groups are standalone components. ## Basic Input Groups The following example demonstrates a basic input group: ## Example
@

.00

$.00
[Try it Β»](#) The result is as follows: ![Image 2: Basic Input Groups](#) ## Input Group Sizing You can change the size of the input group by adding sizing classes relative to the form (e.g., **.input-group-lg**, **.input-group-sm**) to the **.input-group**. The content within the input will automatically resize. The following example demonstrates this: ## Example
@

@

@
[Try it Β»](#) The result is as follows: ![Image 3: Input Group Sizing](#) ## Checkboxes and Radio Addons You can use checkboxes and radio addons as prefix or suffix elements for input groups, as shown in the following example: ## Example

[Try it Β»](#) The result is as follows: ![Image 4: Checkboxes and Radio Addons in Input Groups](#) ## Button Addons You can also use buttons as prefix or suffix elements for input groups. In this case, instead of adding the **.input-group-addon** class, you need to wrap the button using the class **.input-group-btn**. This is necessary because the default browser styles are not overridden. The following example demonstrates this: ## Example

[Try it Β»](#) The result is as follows: ![Image 5: Button Addons in Input Groups](#) ## Buttons with Dropdowns To add buttons with dropdowns in input groups, simply wrap the button and dropdown menu inside an **.input-group-btn** class, as shown in the following example: ## Example [Try it Β»](#) The result is as follows: ![Image 6: Dropdown Buttons in Input Groups](#) ## Segmented Dropdown Buttons To add segmented dropdown buttons in input groups, use a style similar to dropdown buttons, but add primary functionality to the dropdown menu, as shown in the following example: ## Example [Try it Β»](#) The result is as follows: ![Image 7: Segmented Dropdown Buttons in Input Groups](#)
← Bootstrap Navigation ElementsBootstrap Button Dropdowns β†’

YouTip © 2024-2026 | Home | Learn Technology, Build Dreams!

All content is for educational and learning purposes only.