Özer

Inline Validation

Forms 15

About

A controlled text input that validates as you type, crossfading between a hint, an inline error message, and valid/invalid status icons.

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

Code

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

Usage.tsx

"use client";

import { InlineValidation } from "@/components/ui/inline-validation";
import { useState } from "react";

const checkEmail = (v: string) => {
  if (v.trim() === "") return "A work email is required.";
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v))
    return "That is not a complete email address.";
  return null;
};

export default function InviteFormDemo() {
  const [email, setEmail] = useState("");

  return (
    <div className="flex min-h-[280px] w-full items-center justify-center p-6">
      <form
        className="w-full max-w-sm"
        onSubmit={(e) => {
          e.preventDefault();
          if (checkEmail(email)) return;
          alert(`Invite sent to ${email}`);
        }}
      >
        <InlineValidation
          label="Work email"
          type="email"
          value={email}
          onChange={setEmail}
          validate={checkEmail}
          hint="Only used to send the invite."
          autoComplete="email"
          required
        />

        <button
          type="submit"
          className="mt-3 h-9 rounded-[9px] bg-stone-800 px-3 text-[13px] font-medium text-white dark:bg-stone-100 dark:text-stone-900"
        >
          Send invite
        </button>
      </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
  • Book A Demo 3

    Book A Demo 3

    83
  • Authentication Card

    Authentication Card

    47
  • Book A Demo 1

    Book A Demo 1

    69
  • Contact Card

    Contact Card

    1K
  • Login Card

    Login Card

    32
  • Login 2

    Login 2

    7