Install React Application. Install a new React project with following command. Npx create-react-app. Bootstrap 4 Login Form Template Inspirational designs, illustrations, and graphic elements from the world's best designers.
- Bootstrap Form Sample
- Bootstrap 4 Login Form Template Pdf
- Bootstrap 4 Login Form Template Free
- Bootstrap 4 Login Form Template W3schools
Bootstrap 4's Default Settings
Form controls automatically receive some global styling with Bootstrap:
All textual ,
</code>, and <code><select></code> elements with class <code>.form-control</code> have a width of 100%.</p><h2>Bootstrap 4 Form Layouts</h2><p>Bootstrap provides two types of form layouts:</p><ul><li>Stacked (full-width) form</li><li>Inline form</li></ul><h2>Bootstrap 4 Stacked Form</h2><div><label for='pwd'>Password:</label></div><p>The following example creates a stacked form with two input fields, one checkbox, and a submit button.</p><p>Add a wrapper element with <code>.form-group</code>, around each form control, to ensure proper margins:</p><h3>Example</h3><div> <form action='/action_page.php'><br> <div><br> <label for='email'>Email address:</label><br> <input type='email' placeholder='Enter email'><br> </div><br> <div><br> <label for='pwd'>Password:</label><br> <input type='password' placeholder='Enter password'><br> </div><br> <div><br> <label><br> <input type='checkbox'> Remember me<br> </label><br> </div><br> <button type='submit'>Submit</button><br> </form></div>Try it Yourself »<h2>Bootstrap Inline Form</h2><p>In an inline form, all of the elements are inline and left-aligned.</p><p><strong>Note: This only applies to forms within viewports that are at least 576px wide. On screens smaller than 576px, it will stack horizontally.</strong></p>
Additional rule for an inline form:
- Add class
.form-inline
to theelement
The following example creates an inline form with two input fields, one checkbox, and one submit button:
Example
Email address:
Password:
Remember me
Submit
Inline Form with Utilities
The ragtime. The inline form above feels 'compressed', and will look much better with Bootstrap's spacing utilities. The following example adds a right margin (.mr-sm-2
) to each input on all devices (small and up). And a margin bottom class (.mb-2
) is used to style the input field when it breaks (goes from horizontal to vertical due to not enough space/width):
Example
Email address:
Password:
Remember me
Submit
You will learn more about spacing and other 'helper' classes in our Bootstrap 4 Utilities Chapter.
Form Row/Grid
You can also use columns (.col
) to control the width and alignment of form inputs without using spacing utilities. Just remember to put them inside a .row
container.
In the example below, we use two columns that will appear side by side. You will learn much more about columns and rows in the Bootstrap Grids Chapter.
Additional rule for an inline form:
- Add class
.form-inline
to theelement
The following example creates an inline form with two input fields, one checkbox, and one submit button:
Example
Email address:
Password:
Remember me
Submit
Inline Form with Utilities
The ragtime. The inline form above feels 'compressed', and will look much better with Bootstrap's spacing utilities. The following example adds a right margin (.mr-sm-2
) to each input on all devices (small and up). And a margin bottom class (.mb-2
) is used to style the input field when it breaks (goes from horizontal to vertical due to not enough space/width):
Example
Email address:
Password:
Remember me
Submit
You will learn more about spacing and other 'helper' classes in our Bootstrap 4 Utilities Chapter.
Form Row/Grid
You can also use columns (.col
) to control the width and alignment of form inputs without using spacing utilities. Just remember to put them inside a .row
container.
In the example below, we use two columns that will appear side by side. You will learn much more about columns and rows in the Bootstrap Grids Chapter.
Example
If you want less grid margins (override default column gutters), use .form-row
instead of .row
:
Example
Form Validation
You can use different validation classes to provide valuable feedback to users. Add either .was-validated
or .needs-validation
to the
.valid-feedback
or .invalid-feedback
message to tell the user explicitly what's missing, or needs to be done before submitting the form.Example
In this example, we use .was-validated
to indicate what's missing before submitting the form:
Bootstrap Form Sample
Username:
Password:
I agree on blabla.
Submit
Bootstrap 4 Login Form Template Pdf
Try it Yourself »Example
In this example, we use .needs-validation
, which will add the validation effect AFTER the form has been submitting (if there's anything missing). Note that you will also have to add some jQuery code for this example to work properly:
Username:
Password:
I agree on blabla.
Submit
<br>// Disable form submissions if there are invalid fields<br>(function() {<br> 'use strict';<br> window.addEventListener('load', function() {<br> // Get the forms we want to add validation styles to<br> var forms = document.getElementsByClassName('needs-validation');<br> // Loop over them and prevent submission<br> var validation = Array.prototype.filter.call(forms, function(form) {<br> form.addEventListener('submit', function(event) {<br> if (form.checkValidity() false) {<br> event.preventDefault();<br> event.stopPropagation();<br> }<br> form.classList.add('was-validated');<br> }, false);<br> });<br> }, false);<br>})();<br>