A lightweight React international phone number input with taking UX in consideration
npm install react-int-phone-input --save
import React, {useState} from 'react';
import PhoneNumberInput from 'react-int-phone-input';
const App = () => {
const [value, setValue] = useState();
return (
<PhoneInput
value={value}
onChange={setValue}
/>
)
}
You can set the default selected country by using defaultCountry
import React, {useState} from 'react';
import PhoneNumberInput from 'react-int-phone-input';
const App = () => {
const [value, setValue] = useState();
return (
<PhoneInput
value={value}
onChange={setValue}
defaultCountry={'GB'}
/>
)
}
Name | Type | Description | Default | Example |
---|---|---|---|---|
showCountryCode | Boolean | To render the country code in the UI | true | false |
defaultCountry | string | initial country | 'US' | 'US' |