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 form 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">
                    <input class="form-control form-control-xs" type="text" placeholder=".form-control-xs">
                  
                
                  
                    <select class="form-control form-control-lg">
                      <option>Large select</option>
                    </select>
                    <select class="form-control">
                      <option>Default select</option>
                    </select>
                    <select class="form-control form-control-sm">
                      <option>Small select</option>
                    </select>
                    <select class="form-control form-control-xs">
                      <option>Extra small select</option>
                    </select>
                  
                

Custom form

Front customizes Bootstrap's forms, adds some styles to them along with hs.focus-state.js library that adds .u-focus-state classes to control states in various situations.

                  
                    <div class="row">
                      <div class="col-md-6 mb-3 mb-md-0">
                        <div class="js-focus-state input-group mb-2">
                          <div class="input-group-prepend">
                            <span class="input-group-text">
                              <span class="fas fa-user"></span>
                            </span>
                          </div>
                          <input type="email" class="form-control" placeholder="Email" aria-label="Email">
                        </div>

                        <div class="js-focus-state input-group mb-2">
                          <div class="input-group-prepend">
                            <span class="input-group-text">
                              <span class="fas fa-lock"></span>
                            </span>
                          </div>
                          <input type="password" class="form-control" placeholder="Password" aria-label="Password">
                        </div>
                      </div>

                      <div class="col-md-6 mb-3 mb-md-0">
                        <div class="js-focus-state input-group mb-2">
                          <div class="input-group-prepend">
                            <span class="input-group-text">
                              <span class="fas fa-home"></span>
                            </span>
                          </div>
                          <input type="text" class="form-control" placeholder="Readonly" aria-label="Readonly" readonly>
                        </div>

                        <div class="js-focus-state input-group mb-2">
                          <div class="input-group-prepend">
                            <span class="input-group-text">
                              <span class="fas fa-envelope"></span>
                            </span>
                          </div>
                          <input type="text" class="form-control" placeholder="Disabled" aria-label="Disabled" disabled>
                        </div>
                      </div>
                    </div>
                  
                
                  
                    <!-- JS Implementing Plugins -->
                    <script src="../../assets/js/components/hs.focus-state.js"></script>

                    <!-- JS Plugins Init. -->
                    <script>
                      $(document).on('ready', function () {
                        // initialization of forms
                        $.HSCore.components.HSFocusState.init();
                      });
                    </script>
                  
                

Borderless

Add .input-group-borderless to the parent class for an input form without borders.

                  
                    <div class="row">
                      <div class="col-md-6 mb-3 mb-md-0">
                        <div class="input-group-borderless mb-2">
                          <input type="email" class="form-control" placeholder="Email" aria-label="Email">
                        </div>

                        <div class="mb-2">
                          <input type="password" class="form-control" placeholder="Password" aria-label="Password">
                        </div>
                      </div>

                      <div class="col-md-6 mb-3 mb-md-0">
                        <div class="input-group-borderless mb-2">
                          <input type="text" class="form-control" placeholder="Readonly" aria-label="Readonly" readonly>
                        </div>

                        <div class="input-group-borderless mb-2">
                          <input type="text" class="form-control" placeholder="Disabled" aria-label="Disabled" disabled>
                        </div>
                      </div>
                    </div>
                  
                

Pilled form

Use the .input-group-pill modifier class to make badges more rounded (with a larger border-radius and additional horizontal padding).

                  
                    <div class="row">
                      <div class="col-md-6 mb-3 mb-md-0">
                        <div class="input-group-pill mb-2">
                          <input type="email" class="form-control" placeholder="Email" aria-label="Email">
                        </div>

                        <div class="input-group-pill mb-2">
                          <input type="password" class="form-control" placeholder="Password" aria-label="Password">
                        </div>
                      </div>

                      <div class="col-md-6 mb-3 mb-md-0">
                        <div class="input-group-pill mb-2">
                          <input type="text" class="form-control" placeholder="Readonly" aria-label="Readonly" readonly>
                        </div>

                        <div class="input-group-pill mb-2">
                          <input type="text" class="form-control" placeholder="Disabled" aria-label="Disabled" disabled>
                        </div>
                      </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="custom-control custom-checkbox">
                      <input type="checkbox" class="custom-control-input" id="stylishCheckbox">
                      <label class="custom-control-label" for="stylishCheckbox">
                        Stylish checkbox
                      </label>
                    </div>

                    <div class="custom-control custom-checkbox">
                      <input type="checkbox" class="custom-control-input" id="disabledStylishCheckbox" disabled>
                      <label class="custom-control-label" for="disabledStylishCheckbox">
                        Disabled stylish checkbox
                      </label>
                    </div>
                  
                
                  
                    <div class="custom-control custom-radio">
                      <input type="radio" class="custom-control-input" id="stylishRadio">
                      <label class="custom-control-label" for="stylishRadio">
                        Stylish radio
                      </label>
                    </div>

                    <div class="custom-control custom-radio">
                      <input type="radio" class="custom-control-input" id="secondStylishRadio">
                      <label class="custom-control-label" for="secondStylishRadio">
                        Second stylish radio
                      </label>
                    </div>

                    <div class="custom-control custom-radio">
                      <input type="radio" class="custom-control-input" id="disabledStylishRadio" disabled>
                      <label class="custom-control-label" for="disabledStylishRadio">
                        Disabled stylish radio
                      </label>
                    </div>
                  
                

Inline custom checkbox

                  
                    <div class="custom-control custom-checkbox custom-control-inline">
                      <input type="checkbox" id="customCheckboxInline1" name="customCheckboxInline1" class="custom-control-input">
                      <label class="custom-control-label" for="customCheckboxInline1">Toggle this custom checkbox</label>
                    </div>
                    <div class="custom-control custom-checkbox custom-control-inline">
                      <input type="checkbox" id="customCheckboxInline2" name="customCheckboxInline1" class="custom-control-input">
                      <label class="custom-control-label" for="customCheckboxInline2">Or toggle this other custom checkbox</label>
                    </div>
                  
                
                  
                    <div class="custom-control custom-radio custom-control-inline">
                      <input type="radio" id="customRadioInline1" name="customRadioInline1" class="custom-control-input">
                      <label class="custom-control-label" for="customRadioInline1">Toggle this custom radio</label>
                    </div>
                    <div class="custom-control custom-radio custom-control-inline">
                      <input type="radio" id="customRadioInline2" name="customRadioInline1" class="custom-control-input">
                      <label class="custom-control-label" for="customRadioInline2">Or toggle this other custom radio</label>
                    </div>
                  
                

Input group

@
@example.com
https://example.com/users/
$
.00
With textarea
                  
                    <div class="input-group mb-3">
                      <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon1">@</span>
                      </div>
                      <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
                    </div>

                    <div class="input-group mb-3">
                      <input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
                      <div class="input-group-append">
                        <span class="input-group-text" id="basic-addon2">@example.com</span>
                      </div>
                    </div>

                    <label for="basic-url">Your vanity URL</label>
                    <div class="input-group mb-3">
                      <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">https://example.com/users/</span>
                      </div>
                      <input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3">
                    </div>

                    <div class="input-group mb-3">
                      <div class="input-group-prepend">
                        <span class="input-group-text">$</span>
                      </div>
                      <input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
                      <div class="input-group-append">
                        <span class="input-group-text">.00</span>
                      </div>
                    </div>

                    <div class="input-group mb-3">
                      <div class="input-group-prepend">
                        <span class="input-group-text">With textarea</span>
                      </div>
                      <textarea class="form-control" aria-label="With textarea"></textarea>
                    </div>

                    <div class="js-focus-state mb-3">
                      <div class="input-group">
                        <div class="input-group-prepend">
                          <span class="input-group-text">
                            <span class="fas fa-user"></span>
                          </span>
                        </div>
                        <input type="text" class="form-control" placeholder="Username" aria-label="Username">
                      </div>
                    </div>

                    <div class="js-focus-state mb-3">
                      <div class="input-group">
                        <input type="text" class="form-control" placeholder="Username" aria-label="Username">
                        <div class="input-group-append">
                          <span class="input-group-text">
                            <span class="fas fa-user"></span>
                          </span>
                        </div>
                      </div>
                    </div>

                    <div class="js-focus-state mb-3">
                      <div class="input-group input-group-borderless">
                        <div class="input-group-prepend">
                          <span class="input-group-text">
                            <span class="fas fa-user"></span>
                          </span>
                        </div>
                        <input type="text" class="form-control" placeholder="Username" aria-label="Username">
                      </div>
                    </div>

                    <div class="js-focus-state mb-3">
                      <div class="input-group input-group-borderless">
                        <input type="text" class="form-control" placeholder="Username" aria-label="Username">
                        <div class="input-group-append">
                          <span class="input-group-text">
                            <span class="fas fa-user"></span>
                          </span>
                        </div>
                      </div>
                    </div>

                    <div class="js-focus-state mb-3">
                      <div class="input-group input-group-pill">
                        <div class="input-group-prepend">
                          <span class="input-group-text">
                            <span class="fas fa-user"></span>
                          </span>
                        </div>
                        <input type="text" class="form-control" placeholder="Username" aria-label="Username">
                      </div>
                    </div>

                    <div class="js-focus-state mb-3">
                      <div class="input-group input-group-pill">
                        <input type="text" class="form-control" placeholder="Username" aria-label="Username">
                        <div class="input-group-append">
                          <span class="input-group-text">
                            <span class="fas fa-user"></span>
                          </span>
                        </div>
                      </div>
                    </div>
                  
                

Input group 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.

Sizing on the individual input group elements isn’t supported.

Small
Default
Large
                  
                    <div class="input-group input-group-sm mb-3">
                      <div class="input-group-prepend">
                        <span class="input-group-text" id="inputGroup-sizing-sm">Small</span>
                      </div>
                      <input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
                    </div>

                    <div class="input-group mb-3">
                      <div class="input-group-prepend">
                        <span class="input-group-text" id="inputGroup-sizing-default">Default</span>
                      </div>
                      <input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default">
                    </div>

                    <div class="input-group input-group-lg">
                      <div class="input-group-prepend">
                        <span class="input-group-text" id="inputGroup-sizing-lg">Large</span>
                      </div>
                      <input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-lg">
                    </div>