Input
Floating Label Input
A text field whose label rests inside and floats up out of the way when you focus or type.
npx motionsnack add floating-label-inputCustomize
Error Colour
Warning Colour
Success Colour
<FloatingLabelInput />Props
30 properties
| Property | Type | Default | Description |
|---|---|---|---|
| value | string | - | Controlled value. Leave undefined to let the component manage it. |
| defaultValue | string | '' | Value on first render when uncontrolled. |
| onChange | (value: string) => void | - | Called with the new text on every change. |
| name | string | - | Name submitted with a form. |
| autoComplete | string | from type | Native autocomplete hint. |
| clearLabel | string | 'Clear text' | Accessible name of the clear button. |
| invalid | boolean | false | Invalid without its own message. |
| charactersOverLabel | string | '{n} characters too many.' | Error text past the limit. |
| id | string | generated | Id of the input. |
| className | string | '' | Extra classes on the wrapper. |
| label | string | 'Email address' | Label that rests inside the field and floats up on focus or when the field is filled. |
| placeholder | string | '' | Hint inside the field, visible only while the label is floated. |
| helperText | string | 'We only use it to send your receipt.' | Small text under the field. Empty hides it. |
| error | string | '' | Error message. Any text turns the border red and replaces the helper text. |
| type | 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | 'email' | Native input type. |
| icon | 'mail' | 'user' | 'lock' | 'search' | 'none' | 'mail' | Icon at the start of the field. |
| required | boolean | false | Marks the field as required. |
| disabled | boolean | false | Disables the field. |
| readOnly | boolean | false | Focusable and selectable, but not editable. |
| clearable | boolean | false | Clear button while the field has a value. |
| maxLength | number | 0 | Character limit for the counter. 0 = no limit. |
| showCounter | boolean | false | Character counter from 85 % of the limit. |
| warning | string | '' | Warning message in the helper slot. Does not block submit. |
| success | boolean | false | Check at the end after an async check passed. |
| errorColor | string | '' | Error colour for both themes. Empty uses the per-theme pair. |
| warningColor | string | '' | Warning colour for both themes. Empty uses the per-theme pair. |
| successColor | string | '' | Success colour for both themes. Empty uses the per-theme pair. |
| height | number | 48 | Height of the field. |
| radius | number | 12 | Corner radius of the field. |
| duration | number | 0.3 | Seconds the label takes to float up. |
About Floating Label Input
Floating Label Input keeps its label inside the field until you focus it or type, then slides it up and shrinks it out of the way. Focus shows the library's clear outline, white on dark pages and black on light ones. A leading icon, helper text and a required mark are optional, and passing an error message turns the border red and swaps the helper text for the message. The label moves on a CSS transition with a duration you set, skipped for reduced motion, and the field works controlled or uncontrolled.
What's included
- Label that floats on focus or when the field is filled
- Clear focus outline, white on dark and black on light
- Error state with a red border and an alert message
- Optional leading icon from 4 inline SVG icons
- Helper text, required and disabled states
- Controlled and uncontrolled value
- Light and dark look
- Type
- Animated React input component
- Library
- Components · Input
- Stack
- Next.js, React, Tailwind CSS
- Added
- 2026-09-20
- Install
npx motionsnack add floating-label-input