Phone Input
PhoneInput formats as you type and returns E.164, which most SMS and auth APIs expect. Pick a country from the flag, then type a local number to see the result.
@dentil/phone-inputOn this page
—components/demos/phone-input-overview.tsx
'use client';
import { useState } from 'react';
import { PhoneInput } from '@/components/dentil/phone-input/phone-input';
export function PhoneInputOverviewDemo() {
const [phone, setPhone] = useState('');
return (
<div className="flex w-full max-w-xs flex-col gap-4">
<PhoneInput value={phone} onChange={setPhone} defaultCountry="US" aria-label="Phone number" />
<span className="text-muted-foreground text-sm">
Result: <code className="text-foreground">{phone || '—'}</code>
</span>
</div>
);
}Installation
pnpm dlx shadcn@latest add @dentil/phone-inputnpx shadcn@latest add @dentil/phone-inputyarn dlx shadcn@latest add @dentil/phone-inputbunx --bun shadcn@latest add @dentil/phone-inputFiles land in components/dentil/phone-input/. Wraps react-phone-number-input with the stock shadcn input and a flag country picker.
API reference
PhoneInput
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | null | undefined | — | E.164 number, e.g. +447700900123. |
| onChange | (value: string) => void | — | Called with the E.164 number as you type, or '' when cleared. |
| defaultCountry | PhoneCountry | — | Country preselected while the field is empty. |
| countries | PhoneCountry[] | — | Only list these countries. |
| placeholder | string | 'Enter phone number' | Number field placeholder. |
| …props | ComponentProps<'input'> | — | Other props (id, aria-invalid, aria-describedby, onBlur…) are passed to the number input. |