Forms

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

Inputs

Default

<div class="form-group">
    <input type="text" class="form-control" placeholder="Default input">
</div>

Emphasized

<div class="form-group">
    <input type="text" class="form-control form-control-emphasized" placeholder="Emphasized input">
</div>

Muted

<div class="form-group">
    <input type="text" class="form-control form-control-muted" placeholder="Muted input">
</div>

Flushed

<div class="form-group">
    <input type="text" class="form-control form-control-flush" placeholder="Flushed input">
</div>

Masks

Heads up! In order to use the input masks you will need to include additional scripts in the page. See the Input Mask plugin.

<form>
    <div class="form-group">
        <label class="form-control-label">Date</label>
        <input type="text" class="form-control input-mask" data-mask="00/00/0000" placeholder="MM/DD/YYY">
    </div>
    <div class="form-group">
        <label class="form-control-label">Time</label>
        <input type="text" class="form-control input-mask" data-mask="00:00:00" placeholder="hh:mm:ss">
    </div>
    <div class="form-group">
        <label class="form-control-label">Datetime</label>
        <input type="text" class="form-control input-mask" data-mask="00/00/0000 00:00:00" placeholder="MM/DD/YYY hh:mm:ss">
    </div>
    <div class="form-group">
        <label class="form-control-label">Phone number</label>
        <input type="text" class="form-control input-mask" data-mask="0000 000 000" placeholder="0720 444 555">
    </div>
    <div class="form-group">
        <label class="form-control-label">Phone number with prefix</label>
        <input type="text" class="form-control input-mask" data-mask="(00) 0000 0000" placeholder="(99) 5555 6666">
    </div>
    <div class="form-group">
        <label class="form-control-label">US phone number</label>
        <input type="text" class="form-control input-mask" data-mask="(000) 000-0000" placeholder="(99) 5555 6666">
    </div>
    <div class="form-group">
        <label class="form-control-label">Card number</label>
        <input type="text" class="form-control input-mask" data-mask="0000 0000 0000 0000" placeholder="1234 5678 9012 3456">
    </div>
    <div class="form-group">
        <label class="form-control-label">IP address</label>
        <input type="text" class="form-control input-mask" data-mask="000.000.000.0000" placeholder="192.168.567.890">
    </div>
</form>

Options

States

<div class="form-group">
    <input type="text" class="form-control is-valid" placeholder="Is valid">
</div>
<div class="form-group">
    <input type="text" class="form-control is-invalid" placeholder="Is invalid">
</div>
<div class="form-group">
    <input type="text" class="form-control" placeholder="Disabled" disabled>
</div>

Sizing

<div class="form-group">
    <input type="text" class="form-control form-control-xl" placeholder="Extra large input">
</div>
<div class="form-group">
    <input type="text" class="form-control form-control-lg" placeholder="Large input">
</div>
<div class="form-group">
    <input type="text" class="form-control" placeholder="Normal input">
</div>
<div class="form-group">
    <input type="text" class="form-control form-control-sm" placeholder="Small input">
</div>

Textarea

Default

<textarea class="form-control" placeholder="You can manually resize this textarea" rows="3"></textarea>

Non resizable

<textarea class="form-control" placeholder="This is a fixed height textarea" rows="3" resize="none"></textarea>

Autosize

Heads up! Autosize functionality is making use of the Autosize plugin.

<textarea class="form-control" data-toggle="autosize" placeholder="This textarea will autosize while you type" rows="1"></textarea>

Custom forms

Checkboxes

<div class="custom-control custom-checkbox">
    <input type="checkbox" class="custom-control-input" id="customCheck1">
    <label class="custom-control-label" for="customCheck1">Check this custom checkbox</label>
</div>

Custom checkboxes can also utilize the :indeterminate pseudo class when manually set via JavaScript (there is no available HTML attribute for specifying it).

<div class="custom-control custom-checkbox">
    <input type="checkbox" class="custom-control-input" id="customCheck2" data-toggle="indeterminate">
    <label class="custom-control-label" for="customCheck2">Check this custom checkbox</label>
</div>

The best part is that you can make checkboxes look like buttons, using any of the pre-defined colors and styles:

<div class="btn-group btn-group-toggle" data-toggle="buttons">
    <label class="btn btn-primary active">
        <input type="checkbox" name="options" id="checkboxButton1" autocomplete="off" checked> Checkbox button
    </label>
</div>
<div class="btn-group btn-group-toggle" data-toggle="buttons">
    <label class="btn btn-primary active">
        <input type="checkbox" name="options" id="checkboxButton2" autocomplete="off" checked> Active
    </label>
    <label class="btn btn-primary">
        <input type="checkbox" name="options" id="checkboxButton3" autocomplete="off"> Checkbox
    </label>
    <label class="btn btn-primary">
        <input type="checkbox" name="options" id="checkboxButton4" autocomplete="off"> Checkbox
    </label>
</div>

Radios

<div class="custom-control custom-radio">
    <input type="radio" id="customRadio1" name="customRadio" class="custom-control-input">
    <label class="custom-control-label" for="customRadio1">Toggle this custom radio</label>
</div>
<div class="custom-control custom-radio">
    <input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
    <label class="custom-control-label" for="customRadio2">Or toggle this other custom radio</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>

The same thing applies to radio buttons too. Make’em look like buttons, using any of the pre-defined colors and styles:

<div class="btn-group btn-group-toggle" data-toggle="buttons">
    <label class="btn btn-primary active">
        <input type="radio" name="custom-radio-3" id="radioButton1" autocomplete="off"> Radio button
    </label>
</div>
<div class="btn-group btn-group-toggle" data-toggle="buttons">
    <label class="btn btn-primary active">
        <input type="radio" name="custom-radio-2"  id="radioButton2" autocomplete="off" checked> Active
    </label>
    <label class="btn btn-primary">
        <input type="radio" name="custom-radio-2"  id="radioButton3" autocomplete="off"> Radio
    </label>
    <label class="btn btn-primary">
        <input type="radio" name="custom-radio-2"  id="radioButton4" autocomplete="off"> Radio
    </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>

Select menu

<select class="custom-select">
    <option selected>Open this select menu</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
</select>

You may also choose from small and large custom selects to match our similarly sized text inputs.

<select class="custom-select custom-select-lg mb-3">
  <option selected>Open this select menu</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>

<select class="custom-select custom-select-sm">
  <option selected>Open this select menu</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>

Range

Create custom <input type="range"> controls with .custom-range. The track (the background) and thumb (the value) are both styled to appear the same across browsers. As only IE and Firefox support “filling” their track from the left or right of the thumb as a means to visually indicate progress, we do not currently support it.

<label for="customRange1">Example range</label>
<input type="range" class="custom-range" id="customRange1">

Range inputs have implicit values for min and max—0 and 100, respectively. You may specify new values for those using the min and max attributes.

<label for="customRange2">Example range</label>
<input type="range" class="custom-range" min="0" max="5" id="customRange2">

By default, range inputs “snap” to integer values. To change this, you can specify a step value. In the example below, we double the number of steps by using step="0.5".

<label for="customRange3">Example range</label>
<input type="range" class="custom-range" min="0" max="5" step="0.5" id="customRange3">

File browser

<div>
    <input type="file" name="file-1[]" id="file-1" class="custom-input-file" data-multiple-caption="{count} files selected" multiple />
    <label for="file-1">
        <i class="fa fa-upload"></i>
        <span>Choose a file…</span>
    </label>
</div>
<div class="mt-4">
     <input type="file" name="file-2[]" id="file-2" class="custom-input-file custom-input-file--2" data-multiple-caption="{count} files selected" multiple />
    <label for="file-2">
        <i class="fa fa-upload"></i>
        <span>Choose a file…</span>
    </label>
</div>

Validation

Custom styles

For custom Bootstrap form validation messages, you’ll need to add the novalidate boolean attribute to your <form>. This disables the browser default feedback tooltips, but still provides access to the form validation APIs in JavaScript. Try to submit the form below; our JavaScript will intercept the submit button and relay feedback to you. When attempting to submit, you’ll see the :invalid and :valid styles applied to your form controls.

Custom feedback styles apply custom colors, borders, focus styles, and background icons to better communicate feedback. Background icons for <select>s are only available with .custom-select, and not .form-control.

Looks good!
Looks good!
@
Please choose a username.
Please provide a valid city.
Please provide a valid state.
Please provide a valid zip.
You must agree before submitting.
<form class="needs-validation" novalidate>
  <div class="form-row">
    <div class="col-md-4 mb-3">
      <label for="validationCustom01">First name</label>
      <input type="text" class="form-control" id="validationCustom01" placeholder="First name" value="Mark" required>
      <div class="valid-feedback">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationCustom02">Last name</label>
      <input type="text" class="form-control" id="validationCustom02" placeholder="Last name" value="Otto" required>
      <div class="valid-feedback">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationCustomUsername">Username</label>
      <div class="input-group input-group-merge">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend">@</span>
        </div>
        <input type="text" class="form-control" id="validationCustomUsername" placeholder="Username" aria-describedby="inputGroupPrepend" required>
        <div class="invalid-feedback">
          Please choose a username.
        </div>
      </div>
    </div>
  </div>
  <div class="form-row">
    <div class="col-md-6 mb-3">
      <label for="validationCustom03">City</label>
      <input type="text" class="form-control" id="validationCustom03" placeholder="City" required>
      <div class="invalid-feedback">
        Please provide a valid city.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationCustom04">State</label>
      <input type="text" class="form-control" id="validationCustom04" placeholder="State" required>
      <div class="invalid-feedback">
        Please provide a valid state.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationCustom05">Zip</label>
      <input type="text" class="form-control" id="validationCustom05" placeholder="Zip" required>
      <div class="invalid-feedback">
        Please provide a valid zip.
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="form-check">
      <input class="form-check-input" type="checkbox" value="" id="invalidCheck" required>
      <label class="form-check-label" for="invalidCheck">
        Agree to terms and conditions
      </label>
      <div class="invalid-feedback">
        You must agree before submitting.
      </div>
    </div>
  </div>
  <button class="btn btn-primary" type="submit">Submit form</button>
</form>

Browser defaults

Not interested in custom validation feedback messages or writing JavaScript to change form behaviors? All good, you can use the browser defaults. Try submitting the form below. Depending on your browser and OS, you’ll see a slightly different style of feedback.

While these feedback styles cannot be styled with CSS, you can still customize the feedback text through JavaScript.

@
<form>
  <div class="form-row">
    <div class="col-md-4 mb-3">
      <label for="validationDefault01">First name</label>
      <input type="text" class="form-control" id="validationDefault01" placeholder="First name" value="Mark" required>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationDefault02">Last name</label>
      <input type="text" class="form-control" id="validationDefault02" placeholder="Last name" value="Otto" required>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationDefaultUsername">Username</label>
      <div class="input-group input-group-merge">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend2">@</span>
        </div>
        <input type="text" class="form-control" id="validationDefaultUsername" placeholder="Username" aria-describedby="inputGroupPrepend2" required>
      </div>
    </div>
  </div>
  <div class="form-row">
    <div class="col-md-6 mb-3">
      <label for="validationDefault03">City</label>
      <input type="text" class="form-control" id="validationDefault03" placeholder="City" required>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationDefault04">State</label>
      <input type="text" class="form-control" id="validationDefault04" placeholder="State" required>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationDefault05">Zip</label>
      <input type="text" class="form-control" id="validationDefault05" placeholder="Zip" required>
    </div>
  </div>
  <div class="form-group">
    <div class="form-check">
      <input class="form-check-input" type="checkbox" value="" id="invalidCheck2" required>
      <label class="form-check-label" for="invalidCheck2">
        Agree to terms and conditions
      </label>
    </div>
  </div>
  <button class="btn btn-primary" type="submit">Submit form</button>
</form>

Server side

We recommend using client-side validation, but in case you require server-side validation, you can indicate invalid and valid form fields with .is-invalid and .is-valid. Note that .invalid-feedback is also supported with these classes.

Looks good!
Looks good!
@
Please choose a username.
Please provide a valid city.
Please provide a valid state.
Please provide a valid zip.
You must agree before submitting.
<form>
  <div class="form-row">
    <div class="col-md-4 mb-3">
      <label for="validationServer01">First name</label>
      <input type="text" class="form-control is-valid" id="validationServer01" placeholder="First name" value="Mark" required>
      <div class="valid-feedback">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationServer02">Last name</label>
      <input type="text" class="form-control is-valid" id="validationServer02" placeholder="Last name" value="Otto" required>
      <div class="valid-feedback">
        Looks good!
      </div>
    </div>
    <div class="col-md-4 mb-3">
      <label for="validationServerUsername">Username</label>
      <div class="input-group input-group-merge">
        <div class="input-group-prepend">
          <span class="input-group-text" id="inputGroupPrepend3">@</span>
        </div>
        <input type="text" class="form-control is-invalid" id="validationServerUsername" placeholder="Username" aria-describedby="inputGroupPrepend3" required>
        <div class="invalid-feedback">
          Please choose a username.
        </div>
      </div>
    </div>
  </div>
  <div class="form-row">
    <div class="col-md-6 mb-3">
      <label for="validationServer03">City</label>
      <input type="text" class="form-control is-invalid" id="validationServer03" placeholder="City" required>
      <div class="invalid-feedback">
        Please provide a valid city.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationServer04">State</label>
      <input type="text" class="form-control is-invalid" id="validationServer04" placeholder="State" required>
      <div class="invalid-feedback">
        Please provide a valid state.
      </div>
    </div>
    <div class="col-md-3 mb-3">
      <label for="validationServer05">Zip</label>
      <input type="text" class="form-control is-invalid" id="validationServer05" placeholder="Zip" required>
      <div class="invalid-feedback">
        Please provide a valid zip.
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="form-check">
      <input class="form-check-input is-invalid" type="checkbox" value="" id="invalidCheck3" required>
      <label class="form-check-label" for="invalidCheck3">
        Agree to terms and conditions
      </label>
      <div class="invalid-feedback">
        You must agree before submitting.
      </div>
    </div>
  </div>
  <button class="btn btn-primary" type="submit">Submit form</button>
</form>

Examples

Login

<form role="form">
    <div class="form-group">
        <label class="form-control-label">Email address</label>
        <div class="input-group input-group-merge">
            <div class="input-group-prepend">
                <span class="input-group-text"><i class="far fa-user"></i></span>
            </div>
            <input type="email" class="form-control" id="input-email" placeholder="name@example.com">
        </div>
    </div>
    <div class="form-group mb-4">
        <div class="d-flex align-items-center justify-content-between">
            <div>
                <label class="form-control-label">Password</label>
            </div>
            <div class="mb-2">
                <a href="#!" class="small text-muted text-underline--dashed border-primary">Lost password?</a>
            </div>
        </div>
        <div class="input-group input-group-merge">
            <div class="input-group-prepend">
                <span class="input-group-text"><i class="far fa-key"></i></span>
            </div>
            <input type="password" class="form-control" id="input-password" placeholder="Password">
            <div class="input-group-append">
                <span class="input-group-text">
                    <a href="#" data-toggle="password-text" data-target="#input-password">
                        <i class="far fa-eye"></i>
                    </a>
                </span>
            </div>
        </div>
    </div>
    <div class="mt-4"><button type="button" class="btn btn-sm btn-primary btn-icon rounded-pill">
            <span class="btn-inner--text">Sign in</span>
            <span class="btn-inner--icon"><i class="far fa-long-arrow-alt-right"></i></span>
        </button></div>
</form>

Register

<form role="form">
	<div class="form-group">
		<label class="form-control-label">Email address</label>
        <div class="input-group input-group-merge">
            <div class="input-group-prepend">
                <span class="input-group-text"><i class="far fa-user"></i></span>
            </div>
            <input type="email" class="form-control" id="input-email" placeholder="name@example.com">
        </div>
    </div>
    <div class="form-group mb-4">
    	<label class="form-control-label">Password</label>
        <div class="input-group input-group-merge">
            <div class="input-group-prepend">
                <span class="input-group-text"><i class="far fa-key"></i></span>
            </div>
            <input type="password" class="form-control" id="input-password" placeholder="********">
            <div class="input-group-append">
                <span class="input-group-text">
					<a href="#" data-toggle="password-text" data-target="#input-password">
                        <i class="far fa-eye"></i>
                    </a>
                </span>
            </div>
        </div>
    </div>
    <div class="form-group">
    	<label class="form-control-label">Confirm password</label>
        <div class="input-group input-group-merge">
            <div class="input-group-prepend">
                <span class="input-group-text"><i class="far fa-key"></i></span>
            </div>
            <input type="password" class="form-control" id="input-password-confirm" placeholder="********">
        </div>
    </div>
    <div class="my-4">
        <div class="custom-control custom-checkbox mb-3">
            <input type="checkbox" class="custom-control-input" id="check-terms">
            <label class="custom-control-label" for="check-terms">I agree to the <a href="#">terms and conditions</a></label>
        </div>
        <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input" id="check-privacy">
            <label class="custom-control-label" for="check-privacy">I agree to the <a href="#">privacy policy</a></label>
        </div>
    </div>
    <div class="mt-4"><button type="button" class="btn btn-sm btn-primary btn-icon rounded-pill">
            <span class="btn-inner--text">Create my account</span>
            <span class="btn-inner--icon"><i class="far fa-long-arrow-alt-right"></i></span>
        </button></div>
</form>

Reset password

<form role="form">
    <div class="form-group">
        <label class="form-control-label">Email address</label>
        <div class="input-group input-group-merge">
            <div class="input-group-prepend">
                <span class="input-group-text"><i class="far fa-user"></i></span>
            </div>
            <input type="email" class="form-control" id="input-email" placeholder="name@example.com">
        </div>
    </div>
    <div class="mt-4"><button type="button" class="btn btn-sm btn-primary btn-icon rounded-pill">
            <span class="btn-inner--text">Reset password</span>
            <span class="btn-inner--icon"><i class="far fa-long-arrow-alt-right"></i></span>
        </button></div>
</form>

Profile

This is the main email address that we'll send notifications.
<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label class="form-control-label">First name</label>
            <input class="form-control" type="text" placeholder="Enter your first name">
        </div>
    </div>
    <div class="col-md-6">
        <div class="form-group">
            <label class="form-control-label">Last name</label>
            <input class="form-control" type="text" placeholder="Also your last name">
        </div>
    </div>
</div>
<div class="row align-items-center">
    <div class="col-md-6">
        <div class="form-group">
            <label class="form-control-label">Birthday</label>
            <input type="text" class="form-control" data-toggle="date" placeholder="Select your birth date">
        </div>
    </div>
    <div class="col-md-6">
        <div class="form-group">
            <label class="form-control-label">Gender</label>
            <select class="form-control" data-toggle="select">
                <option value="1">Female</option>
                <option value="2">Male</option>
                <option value="2">Rather not say</option>
            </select>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label class="form-control-label">Email</label>
            <input class="form-control" type="email" placeholder="name@exmaple.com">
            <small class="form-text text-muted mt-2">This is the main email address that we'll send notifications.</small>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label class="form-control-label">Phone</label>
            <input class="form-control" type="text" placeholder="+40-777 245 549">
        </div>
    </div>
</div>

Address

<div class="row">
    <div class="col">
        <div class="form-group">
            <label class="form-control-label">Address</label>
            <input class="form-control" type="text" placeholder="Enter your home address">
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label class="form-control-label">City</label>
            <input class="form-control" type="text" placeholder="City">
        </div>
    </div>
    <div class="col-md-6">
        <div class="form-group">
            <label class="form-control-label">Country</label>
            <select class="form-control" data-toggle="select" title="Country" data-live-search="true" data-live-search-placeholder="Country">
                <option>Romania</option>
                <option>United Stated</option>
                <option>France</option>
                <option>Greece</option>
                <option>Italy</option>
                <option>Norway</option>
            </select>
        </div>
    </div>
</div>

Add card

<form role="form">
    <div class="row mt-3">
    <div class="col-md-12">
        <div class="form-group">
            <label class="form-control-label">Card number</label>
            <div class="input-group input-group-merge">
                <input type="text" class="form-control" data-mask="0000 0000 0000 0000" placeholder="4789 5697 0541 7546">
                <div class="input-group-append">
                    <span class="input-group-text"><i class="far fa-credit-card"></i></span>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label class="form-control-label">Name on card</label>
            <input type="text" class="form-control" placeholder="John Doe">
        </div>
    </div>
    <div class="col-md-3">
        <div class="form-group">
            <label class="form-control-label">Expiry date</label>
            <input type="text" class="form-control" data-mask="00/00" placeholder="MM/YY">
        </div>
    </div>
    <div class="col-md-3">
        <div class="form-group">
            <label class="form-control-label">CVV code</label>
            <div class="input-group input-group-merge">
                <input type="text" class="form-control" data-mask="000" placeholder="746">
                <div class="input-group-append">
                    <span class="input-group-text"><i class="far fa-question-circle"></i></span>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="text-right">
    <button type="button" class="btn btn-sm btn-primary rounded-pill">Save card</button>
</div>

</form>