Add

Lorem ipsum

Lorem ipsum

A
A
A
Design

0 views

3 min

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

ClassElementState
form-fieldWrapper div (label + input)Relative container
form-labelLabelAbsolute position, moves on focus
is-filledform-fieldAdded 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.




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();
});

good to know

The :focus-within CSS is enough for the focus animation, but JavaScript is needed to keep the label lifted when the field is filled after blur. Without the JS, the label would drop back down onto the text when the user leaves the field, making the value hard to read.

Conclusion

Floating labels improve the UX of dense forms. See also: designing frictionless forms.

Good to know

Heading

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Lorem ipsum dolor sit amet consectetur.

Lorem ipsum dolor sit amet consectetur. Aliquam orci sagittis dignissim sapien praesent donec.

Lorem ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Published on

You might be interested in these tutorials

Similar tutorials

SEO / GEO

5 min read

5 views

How to Set Up a Redirect in Webflow? (2026)

Updated on 19.12.2025 by Sandro DA SILVA

SEO / GEO

5 min read

5 views

Add structured data to your Webflow site?

Updated on 21.08.2025 by Sandro DA SILVA

No-code

5 min read

5 views

How to Obfuscate a Link in Webflow

Updated on 23.04.2025 by Sandro DA SILVA

Let’s f*****G GO !!

Ready to launch
Your business?

Alexandre

Max

Enora

Bryan

Cannelle

Tiphaine

You'll :heart: our collaboration...