Mark Yo

Phone Input

Forms

About

International phone field with a searchable country picker (emoji flags, dial codes, ~45 built-in countries or your own list), per-country grouping applied as you type without losing the caret, E.164 output with { country, national, valid }, paste-a-full-+number country detection, and a blur-time length check that shakes the field with an inline error.

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

"use client"

import { useState } from "react"
import { PhoneInput, type PhoneValueMeta } from "@/components/ui/karaui-phone-input"

export function PhoneInputPreview() {
  const [e164, setE164] = useState("+6281234567890");
  const [meta, setMeta] = useState<PhoneValueMeta | null>(null);
  const valid = meta ? meta.valid : true;

  return (
    <div className="flex w-full max-w-sm flex-col gap-4">
      <PhoneInput
        label="Phone number"
        value={e164}
        onChange={(next, details) => {
          setE164(next);
          setMeta(details);
        }}
        hint="Paste a full +number to switch country"
      />
      <div className="flex items-center justify-between gap-3 rounded-2xl border border-border bg-muted/40 px-4 py-3">
        <div className="flex min-w-0 flex-col gap-0.5">
          <span className="text-[0.68rem] font-medium uppercase tracking-[0.12em] text-muted-foreground">
            E.164
          </span>
          <code className="truncate font-mono text-sm text-foreground">
            {e164 || "—"}
          </code>
        </div>
        <span
          className={
            valid && e164
              ? "rounded-full bg-(--color-success)/15 px-2.5 py-1 text-xs font-medium text-(--color-success)"
              : "rounded-full bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground"
          }
        >
          {e164 ? (valid ? "Valid" : "Incomplete") : "Empty"}
        </span>
      </div>
    </div>
  );
}

export default PhoneInputPreview

Dependencies

More by Mark Yo

View all
  • Loader

    Loader

    73
  • Pricing Table

    Pricing Table

    33
  • Approval Queue

    Approval Queue

    24
  • Bento Grid

    Bento Grid

    22
  • Expandable Tabs

    Expandable Tabs

    19
  • Image Gallery

    Image Gallery

    17
  • Wallet Card

    Wallet Card

    16
  • Donut Chart

    Donut Chart

    14

More in Forms

View all
  • Form

    Form

    7
  • Login 2

    Login 2

    16
  • Contact Form

    Contact Form

    33
  • Contact Card

    Contact Card

    1.1K
  • Book A Demo 1

    Book A Demo 1

    95
  • Premium Auth

    Premium Auth

    613
  • Onboarding Stepper

    Onboarding Stepper

    13
  • Authentication Card

    Authentication Card

    52