React Native input for validating international phone numbers.
npm install react-native-intl-phone-field
It's a javascript-only (no native code) component that can run in iOS, Android, Expo & React Native Web. Below you can gifs of the demo app that showcases the component in action.
_Click on the image to see it in a larger size_.
A simple that validates and formats international phone numbers using Google's library libphonenumber and phonenumber-js. Works with pre-propulated data and displays an emoji flag if country code is derived from the number. Additionally, adds a + sign infront of the number, so it's considered international.
``sh`
yarn add react-native-intl-phone-field
`js
import IntlPhoneField from 'react-native-intl-phone-field';
onValidation={(isValid) => console.log(isValid)}
defaultCountry="BG"
defaultPrefix="+359"
defaultFlag="đ§đŦ"
/>
`
For more detailed example, take a look at the demo app inside example/.
| Property | Type | Default | Description |
|-------------------|------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| flagUndetermined | string? | â | Displayed when country code cannot be derived from current phone number. |function
| onEndEditing | | undefined | Callback that is called when text input ends text input ends. result
It receives . |function
| onValidation | | undefined | Callback that is called each time the validation status changes. |function
| onValueUpdate | | undefined | Callback that is called each time the underlying value changes. |string
| defaultCountry | | undefined | Two letter code for default country, eg. BG |string
| defaultPrefix | | undefined | Default number prefix, eg. +359 |string
| defaultValue | | undefined | Default value for the TextInput, if you want to pre-populate it. |string
| defaultFlag | | undefined | Emoji for the default flag, eg. đ§đŦ |object
| containerStyle | | undefined | Styles for the component's wrapper |object
| flagContainerStyle | | undefined | Styles for the flag emoji wrapper |object
| flagTextStyle | | undefined | Styles for the flag emoji |object
| textInputStyle | | undefined | Styles for the underlying |object
| textInputProps | | undefined | Additional props for the underlying
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT