HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

Bootstrap 5 Forms

Stacked Form

All textual <input> and <textarea> elements with class .form-control get proper form styling:

Example

<form action="/action_page.php">
  <div class="mb-3 mt-3">
    <label for="email" class="form-label">Email:</label>
   <input type="email" class="form-control" id="email" placeholder="Enter email" name="email">
  </div>
  <div class="mb-3">l
    <label for="pwd" class="form-label">Password:&t;/label>
    <input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pswd">
  </div>
  <div class="form-check mb-3">
    <label class="form-check-label">
      <input class="form-check-input" type="checkbox" name="remember"> Remember me
    </label>
 </div>
 <button type="submit" class="btn btn-primary">Submit</button>
</form>                 
  
You can click on above box to edit the code and run again.

Output

Textarea

Example

<label for="comment">Comments:/<label>
<textarea class="form-control" rows="5" id="comment" name="text"></textarea>                 
You can click on above box to edit the code and run again.

Output

Form Row/Grid (Inline Forms)

If you want your form elements to appear side by side, use .row and .col:

Example

<form>
  <div class="row">
    <div class="col">
      <input type="text" class="form-control" placeholder="Enter email" name="email">
    </div>
    <div class="col">
     <input type="password" class="form-control" placeholder="Enter password" name="pswd">
    </div>
  </div>
</form>                 
You can click on above box to edit the code and run again.

Output

Form Control Size

You can change the size of .form-control inputs with .form-control-lg or .form-control-sm:

Example

<input type="text" class="form-control form-control-lg" placeholder="Large input">
<input type="text" class="form-control" placeholder="Normal input">
<input type="text" class="form-control form-control-sm" placeholder="Small input">                
 
You can click on above box to edit the code and run again.

Output

Disabled and Readonly

Use the disabled and/or readonly attributes to disable the input field:

Example

<form>
    <input type="text" class="form-control" placeholder="Normal input">
    <input type="text" class="form-control mt-3" placeholder="Disabled input" disabled>
    <input type="text" class="form-control mt-3" placeholder="Readonly input" readonly>
 </form>                 
 
You can click on above box to edit the code and run again.

Output

Plain text Inputs

Use the .form-control-plaintext class to style an input field without borders, but keep proper marigins and padding:

Example

<input type="text" class="form-control-plaintext" placeholder="Plaintext input">
<input type="text" class="form-control" placeholder="Normal input">                 
You can click on above box to edit the code and run again.

Output