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
















