FloatingInput

Label floats up on a spring. Errors blur in and the field shakes. Inputs.

Open playground

We never share it.

About

FloatingInput is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { FloatingInput } from "@ashutoshswamy/smoui" and set label, error, hint among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { FloatingInput } from "@ashutoshswamy/smoui";

<FloatingInput label="Email" type="email" name="email" error="Enter a valid email" />

Props 5

label

Floating label, a real <label> bound to the input.

string
error

Error text below the field. Shakes the field when it appears.

string
hint

Helper text below the field.

string
trailing

Content at the right edge, inside the field.

ReactNode
...input props

name, value, onChange, ref and the rest pass through.

InputHTMLAttributes