How to use bootstrap input-group
Overview
While working with input fields, we might want to make it more interactive and intuitive, making users know that they are doing the right thing and helping them ease the process of submitting or filling out a form. The bootstrap input-group helps to do that.
What is input-group?
The input-group is a tag class that bootstrap uses to append or prepend text to an input HTML form tag.
Furthermore, the input-group class is a wrapper to improve the input form fields by prepending or appending an icon, text, or a button to the input form field.
- The
input-group-prependclass adds the group in front of the input.
- The
input-group-prependclass adds the group behind or at the back of the input.
- The
input-group-textclass styles the text inside the group.
Example
Code Explanation
From the code above:
- In line 13: We can observe the
input-groupin theclassattribute of thedivtag. This is a wrapper for theinputtag.
- In line 14: The
input-group-prependis theclassattribute of adivtag that is used to wrap the prepend text to theinputtag.
- In line 15: We use the
input-group-textto append the@sybol to the htmlìnputfield.
- In line 17: We then use the
inputfield withclass="form-control"
Do not forget to add thecsslink and thescriptlink as this the only way you allow bootstrap add styling to your page