Components / component

Floating Input

v1.0.0 · premium

A text field whose label floats up when focused or filled, with an underline that draws in and an accessible error state.

Floating Input demo

Implementation

A text field whose label floats up when focused or filled, with an underline that draws in and an accessible error state.

Framework
React 19.3.1 with TypeScript
Motion
Native CSS and browser APIs. No GSAP required.
Available modes
build
Version
1.0.0 · published

Source code

Download source ZIP
export function FloatingInput({ label, error, hint, ink, className, id, ...input }: Omit<InputHTMLAttributes<HTMLInputEl
  /** The label text. */
  label: string;

Quality evidence

Export tested in 2 consumer projects with chromium, firefox, webkit. Evidence recorded on .

Changelog

v1.0.0 · A text field whose label floats up when focused or filled, with an underline that draws in and an accessible error state.

Frequently asked questions

How does the label know when to float?

It uses the CSS placeholder-shown state on a single-space placeholder, so it floats on focus, when there is a value, and for autofilled values, with no script.

How is the error announced?

The message is linked to the field with aria-describedby, the field gets aria-invalid, and the message is a live alert when it appears.