Bootstrap 5 Form Example on CodePen

Ruth Jul 09, 2026

Bootstrap, the popular CSS framework, has evolved significantly over the years, and its latest iteration, Bootstrap 5, brings a host of improvements and new features. One of the most notable changes is the revamped form components, which are not only more intuitive but also offer better accessibility and responsiveness. Let's explore some Bootstrap 5 form examples using CodePen, a web development platform that allows you to create and share HTML, CSS, and JavaScript snippets.

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

Before diving into the examples, ensure you have the latest Bootstrap 5 CDN linked in your CodePen project. You can add the following line in the 'Settings' tab under 'Include external resources':

Best Free Bootstrap Login Forms » CSS Author
Best Free Bootstrap Login Forms » CSS Author

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">

Now, let's create some Bootstrap 5 form examples.

Basic Form Example

37 Free Bootstrap Form Templates You Can Try Right Now
37 Free Bootstrap Form Templates You Can Try Right Now

Let's start with a simple form that includes text inputs, a textarea, and a submit button.

Here's the HTML code for this example:

Free 22+ HTML5 Signup & Registration Forms - HTML, CSS
Free 22+ HTML5 Signup & Registration Forms - HTML, CSS

<form>
  <div class="mb-3">
    <label for="exampleInputEmail1" class="form-label">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
    <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
  </div>
  <div class="mb-3">
    <label for="exampleInputPassword1" class="form-label">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1">
  </div>
  <div class="mb-3">
    <label for="exampleFormControlTextarea1" class="form-label">Example textarea</label>
    <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

Form Validation

Bootstrap 5 introduces a new form validation system that provides real-time feedback to users. Here's an example of how to use it:

Add the 'is-invalid' and 'is-valid' classes to your input fields to indicate invalid and valid input, respectively. Also, add the 'was-validated' class to the form to enable validation:

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

<form class="needs-validation">
  <div class="mb-3">
    <label for="validationCustom01" class="form-label">First name</label>
    <input type="text" class="form-control" id="validationCustom01" required>
    <div class="valid-feedback">Looks good!</div>
    <div class="invalid-feedback">Please provide a valid first name.</div>
  </div>
  <div class="mb-3">
    <label for="validationCustom02" class="form-label">Last name</label>
    <input type="text" class="form-control" id="validationCustom02" required>
    <div class="valid-feedback">Looks good!</div>
    <div class="invalid-feedback">Please provide a valid last name.</div>
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

Form Layouts

Bootstrap 5 offers various form layouts to help you create responsive and visually appealing forms. Here's an example of a horizontal form layout:

Add the 'row' and 'col' classes to your form groups to create a horizontal layout:

HTML Forms Cheat Sheet for Beginners — Simple Guide
HTML Forms Cheat Sheet for Beginners — Simple Guide

<form>
  <div class="row mb-3">
    <label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail3">
    </div>
  </div>
  <div class="row mb-3">
    <label for="inputPassword3" class="col-sm-2 col-form-label">Password</label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="inputPassword3">
    </div>
  </div>
  <button type="submit" class="btn btn-primary">Sign in</button>
</form>

Advanced Form Example

In this section, we'll create a more complex form that includes form inputs with different types, form checks, and a custom form control.

📝 Create Forms in HTML
📝 Create Forms in HTML
Bootstrap Forms
Bootstrap Forms
40 Best Free Inquiry Form Templates 2026 - Colorlib
40 Best Free Inquiry Form Templates 2026 - Colorlib
Html CSS Responsive Form Design With Full Code Free Template
Html CSS Responsive Form Design With Full Code Free Template
Bootstrap 5.3 (2025) Cheat Sheet
Bootstrap 5.3 (2025) Cheat Sheet
an image of a computer screen with text
an image of a computer screen with text
📝 Create Text Input Forms and Submit Button in HTML
📝 Create Text Input Forms and Submit Button in HTML
BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP
BOOTSTRAP INPUT FORM (2020) | HOW TO MAKE FORM IN BOOTSTRAP
Bootstrap 5 Modal Login Form
Bootstrap 5 Modal Login Form
55 Best Free Bootstrap Registration Form Designs 2026 - Colorlib
55 Best Free Bootstrap Registration Form Designs 2026 - Colorlib
HTML Input Types : A Comprehensive Guide
HTML Input Types : A Comprehensive Guide
Bootstrap 5 Classes List Cheat Sheet
Bootstrap 5 Classes List Cheat Sheet
#CSS Animations Tips and Tricks
#CSS Animations Tips and Tricks
Bootstrap 5 Classes List Cheat Sheet
Bootstrap 5 Classes List Cheat Sheet
Bootstrap 4 Cheat Sheet - The ultimate list of Bootstrap classes
Bootstrap 4 Cheat Sheet - The ultimate list of Bootstrap classes
HTML/CSS|Formの使い方(label, input, select, textarea) - わくわくBank
HTML/CSS|Formの使い方(label, input, select, textarea) - わくわくBank
Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND
Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND
Complete Beginner HTML Master Notes
Complete Beginner HTML Master Notes
Input types in Html
Input types in Html
Semantic HTML Explained Visually (Beginner Guide)
Semantic HTML Explained Visually (Beginner Guide)

Form Inputs with Different Types

Bootstrap 5 supports various input types, such as text, password, email, number, date, and more. Here's an example that includes multiple input types:

Use the appropriate input type for each field, and add the 'form-control' class to style them:

<form>
  <div class="mb-3">
    <label for="exampleInputText" class="form-label">Text</label>
    <input type="text" class="form-control" id="exampleInputText">
  </div>
  <div class="mb-3">
    <label for="exampleInputPassword" class="form-label">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword">
  </div>
  <div class="mb-3">
    <label for="exampleInputEmail" class="form-label">Email</label>
    <input type="email" class="form-control" id="exampleInputEmail">
  </div>
  <div class="mb-3">
    <label for="exampleInputNumber" class="form-label">Number</label>
    <input type="number" class="form-control" id="exampleInputNumber">
  </div>
  <div class="mb-3">
    <label for="exampleInputDate" class="form-label">Date</label>
    <input type="date" class="form-control" id="exampleInputDate">
  </div>
</form>

Form Checks

Bootstrap 5 offers form check inputs, such as checkboxes and radio buttons, which can be easily customized. Here's an example that includes both:

Use the 'form-check' class for the parent element, and the 'form-check-input' class for the input element. Add the 'form-check-label' class to the label element:

<div class="form-check">
  <input type="checkbox" class="form-check-input" id="exampleCheck1">
  <label class="form-check-label" for="exampleCheck1">Check this checkbox</label>
</div>
<div class="form-check">
  <input type="radio" class="form-check-input" id="exampleRadio1" name="exampleRadio">
  <label class="form-check-label" for="exampleRadio1">Radio 1</label>
</div>
<div class="form-check">
  <input type="radio" class="form-check-input" id="exampleRadio2" name="exampleRadio">
  <label class="form-check-label" for="exampleRadio2">Radio 2</label>
</div>

Custom Form Control

You can create custom form controls by combining different Bootstrap components. Here's an example of a custom form control that includes a dropdown and a button:

Wrap the dropdown and the button inside a 'form-control' element to create a custom form control:

<div class="form-control">
  <select class="form-select">
    <option selected>Choose</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
  </select>
  <button type="button" class="btn btn-primary ms-2">Go</button>
</div>

Exploring these Bootstrap 5 form examples on CodePen will help you understand the new features and improvements in the latest version of the framework. Happy coding!