Class 13 of 48 • Forms & Inputs

Bootstrap 5 Form Controls, Checkboxes, Radios & Toggle Switches

Web forms are the primary bridge between users and web applications: handling registrations, logins, payment processing, searches, and feedback. In Bootstrap 5, form styles were completely redesigned with pure custom CSS (no vendor-specific hacky wrappers) to provide identical visual rendering and accessibility across Chrome, Safari, Firefox, Edge, iOS, and Android.

Bootstrap 5 Form Controls, Labels, Checks, Radios, and Switches
Figure 13: Standard form anatomy including textual inputs, disabled states, help text, check boxes, and toggle switches.

1. The Base Form Control (.form-control & .form-label)

Style text inputs, password fields, email inputs, and textareas with .form-control, paired with .form-label for descriptive headings:

<form class="card p-4 shadow-sm">
  <div class="mb-3">
    <label for="exampleEmail" class="form-label">Email Address</label>
    <input type="email" class="form-control" id="exampleEmail" placeholder="student@veewom.com" aria-describedby="emailHelp">
    <div id="emailHelp" class="form-text">We will never share your email with third parties.</div>
  </div>

  <div class="mb-3">
    <label for="examplePassword" class="form-label">Password</label>
    <input type="password" class="form-control" id="examplePassword">
  </div>

  <div class="mb-3">
    <label for="userBio" class="form-label">Your Bio / Comments</label>
    <textarea class="form-control" id="userBio" rows="3"></textarea>
  </div>

  <button type="submit" class="btn btn-primary">Submit Form</button>
</form>

2. Custom Checkboxes & Radio Buttons (.form-check)

Bootstrap 5 replaces clunky default operating system checkboxes and radios with sleek, custom vector SVG checkmarks and radio dots:

<!-- Checkboxes -->
<div class="form-check mb-2">
  <input class="form-check-input" type="checkbox" value="newsletter" id="checkNewsletter" checked>
  <label class="form-check-label" for="checkNewsletter">
    Subscribe to Weekly Tech Newsletter
  </label>
</div>

<!-- Radio Buttons (Share same name attribute for single choice) -->
<div class="form-check">
  <input class="form-check-input" type="radio" name="planChoice" id="planFree" checked>
  <label class="form-check-label" for="planFree">Free Student Tier</label>
</div>
<div class="form-check">
  <input class="form-check-input" type="radio" name="planChoice" id="planPro">
  <label class="form-check-label" for="planPro">Pro Masterclass Tier</label>
</div>

3. Modern Toggle Switches (.form-switch)

Create modern smartphone-style toggle switches simply by adding the .form-switch class to your .form-check container:

<!-- Toggle Switch -->
<div class="form-check form-switch mb-3">
  <input class="form-check-input" type="checkbox" role="switch" id="switchDarkMode">
  <label class="form-check-label" for="switchDarkMode">Enable Dark Theme Mode</label>
</div>

4. Disabled & Read-Only States

Add the disabled or readonly boolean attribute to prevent user input while maintaining accessible contrast:

<input class="form-control mb-2" type="text" placeholder="Disabled Input" disabled>
<input class="form-control" type="text" value="Readonly User ID: #9842" readonly>

Crucial Accessibility Rule

Always match the for attribute on <label> with the id of the <input>. This allows screen readers to announce the label when the input receives focus, and enables users to click on the label text to activate checkboxes or focus inputs!

Explore Related Bootstrap Tutorials & Next Steps

Strengthen your responsive web design mastery by studying these connected classes:

Floating Labels for Inputs

Upgrade standard form inputs to modern material-style floating labels.

Select Menus & Range Sliders

Customize drop-down selects and interactive HTML5 range sliders.

Input Groups & Addons

Prepend and append icons, currency symbols, and buttons to input fields.

Client-Side Form Validation

Implement HTML5 constraint validation with instant green/red feedback.

Frequently Asked Questions (FAQ) - Student & Interview Review

A disabled input is grayed out, cannot receive focus, and its value is NOT submitted with the form. A readonly input cannot be edited by the user, but it CAN receive focus, and its value IS submitted with the form data.
Apply .form-control-lg for larger inputs (great for login pages) or .form-control-sm for compact data entry forms.
Add the .form-check-inline class to your .form-check containers.

Next Step in Your Bootstrap Learning Path:

Advance your practical frontend engineering skills with the next topic in our synchronized curriculum.

Continue to Class 14: Select Menus & Range → Previous: ← Class 12: Buttons & Button Groups | Full Syllabus

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!