ebnsina

Phone Input

Forms

About

A phone number form field that lets you pick or search a country, auto-formats the number as you type, follows a pasted international number to the right country, and shows a plain-language validity message.

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

Code

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

Usage.tsx

import React from "react";
import PhoneInput from "@/components/ui/phone-input";

export default function PhoneInputFormDemo() {
  const [sent, setSent] = React.useState("");

  return (
    <form
      className="grid w-full max-w-sm items-start gap-3"
      onSubmit={(e) => {
        e.preventDefault();
        setSent(String(new FormData(e.currentTarget).get("phone")));
      }}
    >
      <PhoneInput
        label="Phone for the reading room"
        name="phone"
        country="TR"
        required
        className="w-full"
      />
      <button
        type="submit"
        className="inline-flex h-9 items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground"
      >
        Book a desk
      </button>
      <p role="status" className="text-sm text-muted-foreground tabular-nums">
        {sent ? `Would send phone=${sent}` : ""}
      </p>
    </form>
  );
}

Dependencies

More by ebnsina

View all
  • Countdown Timer

    Countdown Timer

    35
  • Video Player

    Video Player

    26
  • Alarm Clock

    Alarm Clock

    24
  • Hourglass Timer

    Hourglass Timer

    20
  • Voice Note

    Voice Note

    19
  • Sortable List

    Sortable List

    18
  • Sign In Auth Card

    Sign In Auth Card

    14
  • Split Button

    Split Button

    13

More in Forms

View all
  • Premium Auth

    Premium Auth

    592
  • Login 1

    Login 1

    70
  • Contact Card

    Contact Card

    1.1K
  • Contact Form

    Contact Form

    28
  • Form

    Form

    6
  • HeroUI Field Error

    HeroUI Field Error

    13
  • Form

    Form

    4
  • Book A Demo 4

    Book A Demo 4

    69