Basic Forms

Tabs styles and versions
We'll never share your email with anyone else.

Form controls

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

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

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


Sizing

Set heights using classes like .form-control-lgand .form-control-sm.

Add the readonlyboolean attribute on an input to prevent modification of the input’s value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor.

If you want to have <input readonly>elements in your form styled as plain text, use the .form-control-plaintextclass to remove the default form field styling and preserve the correct margin and padding.

Here are examples of .form-controlapplied to each textual HTML5 <input>type.

Use the .form-inlineclass to display a series of labels, form controls, and buttons on a single horizontal row. Form controls within inline forms vary slightly from their default states.

@

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

Custom checkboxes and radios can also be disabled. Add the disabledboolean attribute to the <input>and the custom indicator and label description will be automatically styled.

A switch has the markup of a custom checkbox but uses the .custom-switchclass to render a toggle switch. Switches also support the disabledattribute.

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.

Range inputs have implicit values for minand max0and 100, respectively. You may specify new values for those using the minand maxattributes.

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

Checkboxes

Basic

Supports bootstrap brand colors: .checkbox-primary, .checkbox-infoetc.

Inline checkboxes

Circled

.checkbox-circlefor roundness.

Disabled

Disabled state also supported.

Radios

Basic

Supports bootstrap brand colors: .radio-primary, .radio-dangeretc.

Inline radios

Disabled

Disabled state also supported.

For custom Bootstrap form validation messages, you’ll need to add the novalidateboolean 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 :invalidand :validstyles 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.

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.

@

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-invalidand .is-valid. Note that .invalid-feedbackis 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.

Supported elements

Validation styles are available for the following form controls and components:

  • <input>s and <textarea>s with .form-control(including up to one .form-controlin input groups)
  • <select>s with .form-selector .custom-select
  • .form-checks
  • .custom-checkboxs and .custom-radios
  • .custom-file
Please enter a message in the textarea.
Example invalid feedback text
More example invalid feedback text
Example invalid custom select feedback
Example invalid custom file feedback

Tooltips

If your form layout allows it, you can swap the .{valid|invalid}-feedbackclasses for .{valid|invalid}-tooltipclasses to display validation feedback in a styled tooltip. Be sure to have a parent with position: relativeon it for tooltip positioning. In the example below, our column classes have this already, but your project may require an alternative setup.

Looks good!
Looks good!
@
Please choose a unique and valid username.
Please provide a valid city.
Please provide a valid state.
Please provide a valid zip.