Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions content/docs/components/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Choose a region and read back the locale defaults that come with it — for sett

International phone number input with country selector and dial code search.

| Component | Description |
| ------------------------------------------------------ | -------------------------------------------------------------------- |
| **[Phone Input](/docs/components/inputs/phone-input)** | Country selector with flags, dial codes, and search for 50 countries |
| Component | Description |
| ------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| **[Phone Input](/docs/components/inputs/phone-input)** | Country selector with flags, dial codes, and search for every E.164 country (~244 entries) |

### Navigation

Expand Down
138 changes: 96 additions & 42 deletions content/docs/components/inputs/phone-input.mdx

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions src/components/docs/phone-input-demo.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
"use client";

import { useState } from "react";
import { PhoneInput } from "@/registry/components/phone-input";

export function PhoneInputDemo() {
const [e164, setE164] = useState("");
return (
<PhoneInput
defaultCountry="US"
placeholder="(555) 000-0000"
onValueChange={(phone, country) => console.log("Phone:", country.dialCode, phone)}
size="default" // sm, default, lg
className="w-full max-w-xs"
/>
<div className="w-full max-w-xs space-y-2">
<PhoneInput
defaultCountry="US"
placeholder="(555) 000-0000"
preferredCountries={["IN", "GB"]} // pinned above the full list
validate // marks a malformed number aria-invalid
onValueChange={(phone, country) => console.log("Phone:", country.dialCode, phone)}
onValidityChange={(valid, value) => setE164(valid ? value : "")}
size="default" // sm, default, lg
className="w-full"
/>
<p className="text-xs text-muted-foreground">
{e164 ? `E.164: ${e164}` : "Type a phone number"}
</p>
</div>
);
}
Loading
Loading