Also see the official documentation
Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms.
Here’s a quick example to demonstrate Bootstrap’s form styles. Keep reading for documentation on required classes, form layout, and more.
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.
Set heights using classes like .form-control-lg
and .form-control-sm
.
Add the readonly
boolean 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-plaintext
class to remove the default form field styling and preserve the correct margin and padding.
Block-level help text in forms can be created using .form-text
(previously known as .help-block
in v3). Inline help text can be flexibly implemented using any inline HTML element and utility classes like .text-muted
.
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.
Each checkbox and radio <input>
and <label>
pairing is wrapped in a <div>
to create our custom control. Structurally, this is the same approach as our default .form-check
.
We hide the default file <input>
via opacity
and instead style the <label>
. The button is generated and positioned with ::after
. Lastly, we declare a width
and height
on the <input>
for proper spacing for surrounding content.
Read more
Field to select a file with drag and drop function.