Design3 min read
How to Create Floating Labels on Webflow Inputs
Learn how to create floating labels on Webflow inputs with CSS transitions and JavaScript.
In this tutorial, Sandro, cofounder of Gemeos Webflow agency, shows you how to create floating labels on Webflow inputs: the label lifts above the field when the user starts typing.
Example
| Class | Element | State |
|---|---|---|
| form-field | Wrapper div (label + input) | Relative container |
| form-label | Label | Absolute position, moves on focus |
| is-filled | form-field | Added when the input has a value |
1. HTML structure in an Embed
Create the structure below in a Webflow Embed. The label and the input need to live in the same relative container.
<div class="form-field">
<label class="form-label">Email</label>
<input type="email" class="form-input">
</div>2. The CSS
.form-field { position: relative; padding-top: 16px; }
.form-label {
position: absolute;
top: 28px;
left: 12px;
font-size: 16px;
color: #9ca3af;
transition: all 0.2s ease;
pointer-events: none;
}
.form-field.is-filled .form-label,
.form-field:focus-within .form-label {
top: 2px;
font-size: 11px;
color: #6b7280;
}3. The script
document.querySelectorAll('.form-field').forEach(function(field) {
var input = field.querySelector('input, textarea');
if (!input) return;
function toggle() {
field.classList.toggle('is-filled', input.value.length > 0);
}
input.addEventListener('input', toggle);
input.addEventListener('blur', toggle);
toggle();
});Conclusion
Floating labels improve the UX of dense forms. See also: designing frictionless forms.


