Özer

Floating Label

Forms 16

About

A text input whose label animates up into a reserved slot above the field instead of disappearing, with focus/invalid states, an optional hint line and a character counter.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Floating Label to your project and fits it to your theme.

Code

How Floating Label is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import * as React from "react";
import { FloatingLabelInput } from "@/components/ui/floating-label";

export default function BillingContact() {
  const [email, setEmail] = React.useState("");
  const [reference, setReference] = React.useState("");
  const [touched, setTouched] = React.useState(false);

  const bad = touched && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);

  return (
    <div className="flex justify-center">
      <form className="grid w-full max-w-[320px] gap-4">
        <FloatingLabelInput
          label="Work email"
          type="email"
          autoComplete="email"
          required
          value={email}
          onChange={setEmail}
          onBlur={() => setTouched(true)}
          invalid={bad}
          hint={
            bad
              ? "Needs to look like name@company.com"
              : "Receipts are sent here."
          }
        />

        <FloatingLabelInput
          label="Invoice reference"
          value={reference}
          onChange={setReference}
          maxLength={16}
          hint="Printed on the statement header."
        />
      </form>
    </div>
  );
}

Dependencies

More by Özer

View all
  • Password Strength

    Password Strength

    1.3K
  • OTP Input

    OTP Input

    803
  • Loading Button

    Loading Button

    602
  • Progress Bar

    Progress Bar

    588
  • Reorder List

    Reorder List

    310
  • Task Steps

    Task Steps

    276
  • Hold to Confirm

    Hold to Confirm

    250
  • Reading Progress

    Reading Progress

    169

More in Forms

View all
  • Premium Auth

    Premium Auth

    500
  • Login 1

    Login 1

    52
  • Authentication Card

    Authentication Card

    47
  • Book A Demo 3

    Book A Demo 3

    83
  • Book A Demo 1

    Book A Demo 1

    69
  • Contact Card

    Contact Card

    1K
  • Login Card

    Login Card

    32
  • Login 2

    Login 2

    7