Bootstrap 5 floating labels animate the input label to float above the field when focused or filled. This page covers 4 floating label patterns — basic, select, validation and login form.

Quick Setup

Floating labels need Bootstrap 5.1+ CSS:

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

Key Pattern

<div class="form-floating">
  <input type="text" class="form-control" id="myInput" placeholder="Required for animation">
  <label for="myInput">Your Label</label>
</div>

Critical: label must come AFTER the input. Placeholder is required.

Key Classes Reference

ClassWhat It Does
.form-floatingWrapper that enables floating label
.form-controlInput inside floating label
.form-selectSelect inside floating label
placeholderRequired attribute for animation

1. Basic Bootstrap 5 Floating Labels

Floating labels that animate to the top when the input is focused or has content.

2. Bootstrap 5 Floating Label Select

Floating labels also work on select dropdowns using form-floating with form-select.

3. Bootstrap 5 Floating Label with Validation

Floating labels with Bootstrap's is-valid and is-invalid validation states.

4. Bootstrap 5 Login Form with Floating Labels

A complete login form using floating labels — clean modern style.

Frequently Asked Questions

Wrap an input and its label in a div with class form-floating. Set a placeholder on the input (required for the animation to work). The label starts inside the input and floats to the top when the input is focused or has content. Bootstrap handles all the CSS animation.
The input must have a placeholder attribute — this is required for Bootstrap's floating label CSS to work. Even an empty placeholder works: placeholder=' '. Without it the label stays at the top and doesn't float. Also make sure the label is placed AFTER the input inside form-floating.
Yes. Use form-select instead of form-control on the select element inside a form-floating div. The label floats automatically. Note: a placeholder option with empty value is recommended as the default selected option.
Add is-valid or is-invalid directly to the input class. Add valid-feedback or invalid-feedback divs after the label inside form-floating. The validation feedback displays below the input just like standard Bootstrap validation.

Need a Full Bootstrap 5 Admin Dashboard?

Get a complete Angular 21 + Bootstrap 5 dashboard with 50+ components — built by the same team behind BootstrapPlanet.

Browse Templates →

Use code FIRST30 for 30% off your first purchase.

Related Components