PhoneInput
Phone number with a searchable country-code dropdown (search by country or +code) and a tel input.
Code
import * as React from 'react';
import { PhoneInput } from '@fruit-labs/design';
export default function Demo() {
return (
<div
style={{
maxWidth: 360,
}}
>
<PhoneInput
label="Mobile number"
required
defaultValue="98765 43210"
hint="We’ll send a code to verify it."
/>
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { PhoneInput } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/phone-input.jsonGuidelines
- Default country is India (+91); set
defaultCountry. Storecountryand the national number separately; format to E.164 on the server. - Pass your own
countrieslist as [ISO, name, dial] triples.
Props
| Prop | Type | Required |
|---|---|---|
value | string | No |
defaultValue | string | No |
onChange | (number: string) => void | No |
country | string | No |
defaultCountry | string | No |
onCountryChange | (iso: string) => void | No |
countries | Array<[string, string, string]> | No |
label | string | No |
hint | React.ReactNode | No |
error | React.ReactNode | No |
required | boolean | No |
placeholder | string | No |
size | 'sm' | 'md' | No |
className | string | No |
style | React.CSSProperties | No |