Floating Label V2
An outline-only field with no fill: its label climbs astride the top edge while shrinking to 85%, and the line breaks just behind it. CSS only.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Forms has 21 effects, including 2 free. Explore the category →
3 usage examples



How it works
The field has nothing but a 2 px frame, indigo at 30% at rest, and lets the page show through. The .flv-label text sits inside it, vertically centred. Two situations send it up onto the top edge: the field has focus, or it holds something (:not(:placeholder-shown), made possible by a placeholder=" " reduced to one space). Where the value comes from does not matter: typing, a value attribute already in the HTML or a value written by a script give the same result in Chromium, Firefox and WebKit.
On its way up the label is not rewritten in a smaller font: it keeps its size and goes through transform: scale(.85), in one 0.3 s move together with its shift. At the same moment it gets a background, --flv-notch, and 8 px of padding on each side: that small rectangle hides the frame line behind the text, and it is what draws the notch.
The frame only turns solid indigo while the field has focus. A field that was filled and then left goes back to its faint outline and keeps just its coloured label at the top. In a grid of fields that already hold values, the one being typed in is therefore the only one lit.
A label too long for the field stays on one line and ends with an ellipsis. The .fx-0291-root root supplies the demo backdrop (dark background, 300 px tall) and the box-sizing: in your form, keep it and cancel its backdrop with min-height: 0; padding: 0; background: transparent.
Accessibility
- A real label: the text that moves up is the content of the
<label>wrapping the field. Noidto make up, a click on the text puts the caret in the field, and screen readers keep announcing "Email address" once the text has moved. - Measured contrast: label at rest
#a1a1aa, 7.7:1 on the demo background; raised label#818cf8, 6.6:1 for 13.6 px text. The frame at rest is pale on purpose (1.4:1): the label is what signals the field. For a firmer outline, strengthen--flv-border. - Active field: the frame turns solid indigo, with no halo. When the system imposes its colours (Windows high-contrast mode), a 2 px outline takes over; without it, Firefox showed no difference between a filled field and the same field in focus.
- Input errors: the effect has no error state. The kayak course example shows one way to do it without adding a rule:
aria-invalidandaria-describedbyon the field, arole="alert"message below it, and three colour variables turned pink on the root. - Reduced motion: with
prefers-reduced-motion: reduce, the label lands at the top at once and the frame changes colour without a fade. - Touch: the field is 46 px tall and its text 16 px. If you lower
--flv-font-sizebelow 16 px, Safari on iPhone zooms into the field on tap (a known behaviour of that browser, not measured here).
Browser compatibility
Only two building blocks: :placeholder-shown (Chrome 47, Firefox 51, Safari 9) and CSS variables (Chrome 49, Firefox 31, Safari 9.1), versions taken from @mdn/browser-compat-data. Tried on 04/12/2026 in Chromium 149, Firefox 151 and WebKit 26.5: two copies on one page (the second filled from the keyboard while the first stays still), value present in the HTML, value written by script, touch on a 390 px screen, reduced motion, forced colours. Browser autofill could not be replayed in an automated test.
A pre-2017 browser that does not know :placeholder-shown lets the label drop back over the value as soon as the field loses focus: the effect is not meant for it. No script is involved, so nothing changes when JavaScript is blocked.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0291-root">
<label class="flv-field">
<input class="flv-input" type="email" name="email" autocomplete="email" placeholder=" ">
<span class="flv-label">Email address</span>
</label>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Width (CSS — --flv-width) |
280px | A length, or 100% to match the column. The field never exceeds its parent (max-width: 100%). |
Notch background (CSS — --flv-notch) |
#0a0a0f | The flat colour of whatever sits behind the field. Over a photo or a gradient the small rectangle would show: the effect needs a solid colour. |
Frame (CSS — --flv-border, --flv-accent) |
indigo at 30% · #6366f1 | Outline at rest, outline while in focus. |
Texts (CSS — --flv-text, --flv-muted, --flv-accent-text) |
#fff · #a1a1aa · #818cf8 | Typed value, label inside the field, raised label. On a light background darken all three (see the chess club example) and aim for 4.5:1 on the raised label, which is small. |
Text size (CSS — --flv-font-size) |
1rem | Sets the field and the label together; once raised, the label is always 85% of that size. |
Shrink and duration (CSS — scale(.85), transition) |
.85 · 0.3 s | In the raised-label rule and on .flv-input / .flv-label. Below .75 the label gets hard to read; beyond 0.4 s it lags behind typing. |
| Kind of field (HTML) | type="email" name="email" autocomplete="email" |
Text, phone, number: change these attributes, not the placeholder=" ", without which the label can no longer tell whether the field is empty. |
FAQ
#0a0a0f by default, and cannot guess your page's. Give --flv-notch the right value on the field or on a parent (#fff for a white card).id and link it to the field with aria-describedby. When the value is rejected, set aria-invalid="true", show the message (role="alert" gets it announced) and turn --flv-border, --flv-accent and --flv-accent-text to your error colour on the root. That check remains your code: the effect validates nothing.