Forms

Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms with the help of Bootstrap Forms.

Overview

Bootstrap's form controls expand on Bootstrap Rebooted form styles with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices.

Be sure to use an appropriate type attribute on all inputs (e.g., email for email address or number for numerical information) to take advantage of newer input controls like email verification, number selection, and more.

For more information, see Bootstrap Forms

Here's a quick example to demonstrate Bootstrap's form styles. Keep reading for documentation on required classes, form layout, and more.

We'll never share your email with anyone else.
                            
                              <form>
                                <div class="form-group">
                                  <label for="exampleInputEmail1">Email address</label>
                                  <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
                                  <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
                                </div>
                                <div class="form-group">
                                  <label for="exampleInputPassword1">Password</label>
                                  <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
                                </div>
                                <div class="form-group form-check">
                                  <input type="checkbox" class="form-check-input" id="exampleCheck1">
                                  <label class="form-check-label" for="exampleCheck1">Check me out</label>
                                </div>
                                <button type="submit" class="btn btn-primary">Submit</button>
                              </form>
                            
                          

Form controls

Textual form controls—like <input>s, <select>s, and <textarea>s—are styled with the .form-control class. Included are styles for general appearance, focus state, sizing, and more.

Be sure to explore our custom forms to further style <select>s.

                            
                              <form>
                                <div class="form-group">
                                  <label for="exampleFormControlInput1">Email address</label>
                                  <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com">
                                </div>
                                <div class="form-group">
                                  <label for="exampleFormControlSelect1">Example select</label>
                                  <select class="form-control" id="exampleFormControlSelect1">
                                    <option>1</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                  </select>
                                </div>
                                <div class="form-group">
                                  <label for="exampleFormControlSelect2">Example multiple select</label>
                                  <select multiple class="form-control" id="exampleFormControlSelect2">
                                    <option>1</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                  </select>
                                </div>
                                <div class="form-group">
                                  <label for="exampleFormControlTextarea1">Example textarea</label>
                                  <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
                                </div>
                              </form>
                            
                          

For file inputs, swap the .form-control for .form-control-file.

                            
                              <form>
                                <div class="form-group">
                                  <label for="exampleFormControlFile1">Example file input</label>
                                  <input type="file" class="form-control-file" id="exampleFormControlFile1">
                                </div>
                              </form>
                            
                          

Sizing

Set heights using classes like .form-control-lg and .form-control-sm.

                            
                              <input class="form-control form-control-lg" type="text" placeholder=".form-control-lg">
                              <input class="form-control" type="text" placeholder="Default input">
                              <input class="form-control form-control-sm" type="text" placeholder=".form-control-sm">
                            
                          
                            
                              <select class="custom-select custom-select-lg">
                                <option>Large select</option>
                              </select>
                              <select class="custom-select">
                                <option>Default select</option>
                              </select>
                              <select class="custom-select custom-select-sm">
                                <option>Small select</option>
                              </select>
                            
                          

Custom form

For even more customization and cross browser consistency, use our completely custom form elements to replace the browser defaults. They’re built on top of semantic and accessible markup, so they’re solid replacements for any default form control.

With Prepend

Place one add-on on left side of an input.

Bitcoin Cash
                            
                              <div class="input-group">
                                <div class="input-group-prepend">
                                  <img class="icon-img" src="../../assets/svg/crypto/bitcoin-cash.svg" alt="Bitcoin Cash">
                                </div>
                                <input class="form-control form-control-icon-img" placeholder="Placeholder" type="text">
                              </div>
                            
                          

With Append

Place one add-on on right side of an input.

                            
                              <div class="input-group">
                                <div class="input-group-append">
                                  <i class="nova-search icon-text icon-text-sm"></i>
                                </div>
                                <input class="form-control form-control-icon-text" placeholder="Search" type="text">
                              </div>
                            
                          

With Append Button

Place one button on right side of an input.

                            
                              <div class="input-group">
                                <input class="form-control" placeholder="https://themes.getbootstrap.com/store/htmlstream/" type="text">
                                <div class="input-group-append input-group-append-infinity">
                                  <a class="btn btn-sm btn-primary" href="#">Search</a>
                                </div>
                              </div>
                            
                          

With Append Icon

                            
                              <div class="input-group">
                                <input type="text" class="form-control form-control-onfocus-inherit bg-transparent small text-muted" value="0xe99356bde974bbe08721d77712168fa070aa8da4" readonly="">

                                <div class="input-group-append input-group-append-simple">
                                  <a class="input-group-text bg-transparent text-muted" href="#">
                                    <i class="nova-layers icon-text icon-text-sm"></i>
                                  </a>
                                </div>
                              </div>
                            
                          

Checkbox and radios

Default checkboxes and radios are improved upon with the help of .form-check, a single class for both input types that improves the layout and behavior of their HTML elements. Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.

Disabled checkboxes and radios are supported, but to provide a not-allowed cursor on hover of the parent <label>, you’ll need to add the disabled attribute to the .form-check-input. The disabled attribute will apply a lighter color to help indicate the input’s state.

Checkboxes and radios use are built to support HTML-based form validation and provide concise, accessible labels. As such, our <input>s and <label>s are sibling elements as opposed to an <input> within a <label>. This is slightly more verbose as you must specify id and for attributes to relate the <input> and <label>.

Default (stacked)

By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with .form-check.

                            
                              <div class="form-check">
                                <input class="form-check-input" type="checkbox" value="" id="defaultCheck1">
                                <label class="form-check-label" for="defaultCheck1">
                                  Default checkbox
                                </label>
                              </div>
                              <div class="form-check">
                                <input class="form-check-input" type="checkbox" value="" id="defaultCheck2" disabled>
                                <label class="form-check-label" for="defaultCheck2">
                                  Disabled checkbox
                                </label>
                              </div>
                            
                          
                            
                              <div class="form-check">
                                <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
                                <label class="form-check-label" for="exampleRadios1">
                                  Default radio
                                </label>
                              </div>
                              <div class="form-check">
                                <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios2" value="option2">
                                <label class="form-check-label" for="exampleRadios2">
                                  Second default radio
                                </label>
                              </div>
                              <div class="form-check">
                                <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios3" value="option3" disabled>
                                <label class="form-check-label" for="exampleRadios3">
                                  Disabled radio
                                </label>
                              </div>
                            
                          

Inline checkbox

Group checkboxes or radios on the same horizontal row by adding .form-check-inline to any .form-check.

                            
                              <div class="form-check form-check-inline">
                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
                                <label class="form-check-label" for="inlineCheckbox1">1</label>
                              </div>
                              <div class="form-check form-check-inline">
                                <input class="form-check-input" type="checkbox" id="inlineCheckbox2" value="option2">
                                <label class="form-check-label" for="inlineCheckbox2">2</label>
                              </div>
                              <div class="form-check form-check-inline">
                                <input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3" disabled>
                                <label class="form-check-label" for="inlineCheckbox3">3 (disabled)</label>
                              </div>
                            
                          
                            
                              <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
                                <label class="form-check-label" for="inlineRadio1">1</label>
                              </div>
                              <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
                                <label class="form-check-label" for="inlineRadio2">2</label>
                              </div>
                              <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" disabled>
                                <label class="form-check-label" for="inlineRadio3">3 (disabled)</label>
                              </div>
                            
                          

Custom checkbox

                            
                              <div class="form-check position-relative mb-2">
                                <input type="checkbox" class="form-check-input d-none" id="customCheckboxes1">
                                <label class="checkbox checkbox-xxs form-check-label ml-1" for="customCheckboxes1"
                                       data-icon="&#xe936">Checkbox label</label>
                              </div>

                              <div class="form-check position-relative mb-2">
                                <input type="checkbox" class="form-check-input d-none" id="customCheckboxes2">
                                <label class="checkbox checkbox-xxs form-check-label ml-1" for="customCheckboxes2"
                                       data-icon="&#xe936">Checkbox label</label>
                              </div>
                            
                          
                            
                              <div class="form-check position-relative mb-2">
                                <input type="radio" class="form-check-input d-none" id="customRadioboxes1" name="customRadioboxes">
                                <label class="radio radio-xxs form-check-label ml-1" for="customRadioboxes1"
                                       data-icon="">Radio label</label>
                              </div>

                              <div class="form-check position-relative mb-2">
                                <input type="radio" class="form-check-input d-none" id="customRadioboxes2" name="customRadioboxes">
                                <label class="radio radio-xxs form-check-label ml-1" for="customRadioboxes2"
                                       data-icon="">Radio label</label>
                              </div>
                            
                          

Switches

                            
                              <div class="custom-control custom-switch">
                                <input type="checkbox" class="custom-control-input" id="customSwitch1">
                                <label class="custom-control-label" for="customSwitch1">Toggle this switch element</label>
                              </div>
                              <div class="custom-control custom-switch">
                                <input type="checkbox" class="custom-control-input" disabled id="customSwitch2">
                                <label class="custom-control-label" for="customSwitch2">Disabled switch element</label>
                              </div>