Gathering detailed insights and metrics for react-native-phone-input
Gathering detailed insights and metrics for react-native-phone-input
Gathering detailed insights and metrics for react-native-phone-input
Gathering detailed insights and metrics for react-native-phone-input
react-native-phone-number-input
Phone Number Input Component
react-native-bpk-component-phone-input
Backpack React Native phone input component.
@nandorojo/react-native-phone-input
Phone input box for React Native, forked by Doorman.
@pkayfire/react-native-phone-input
Phone input box for React Native
npm install react-native-phone-input
Typescript
Module System
Node Version
NPM Version
TypeScript (90.61%)
JavaScript (5.21%)
Shell (4.18%)
Total Downloads
3,383,037
Last Day
623
Last Week
13,164
Last Month
51,660
Last Year
684,559
MIT License
48 Stars
151 Commits
62 Forks
1 Watchers
2 Branches
Updated on May 24, 2025
Latest Version
1.3.7
Package Id
react-native-phone-input@1.3.7
Unpacked Size
1.92 MB
Size
1.66 MB
File Count
264
NPM Version
9.6.7
Node Version
20.3.0
Published on
Jul 28, 2023
Cumulative downloads
Total Downloads
Last Day
55.4%
623
Compared to previous day
Last Week
6.5%
13,164
Compared to previous week
Last Month
-20.8%
51,660
Compared to previous month
Last Year
2.6%
684,559
Compared to previous year
3
2
21
Demo of Phone Input box for React Native (android/ios)
![]() | ![]() |
---|
npm i react-native-phone-input --save
1import PhoneInput from 'react-native-phone-input' 2 3render(){ 4 return( 5 <PhoneInput ref='phone'/> 6 ) 7}
(android/ios)
![]() | ![]() |
---|
1componentDidMount(){ 2 this.setState({ 3 pickerData: this.phone.getPickerData() 4 }) 5} 6 7onPressFlag(){ 8 this.myCountryPicker.open() 9} 10 11selectCountry(country){ 12 this.phone.selectCountry(country.iso2) 13} 14 15render(){ 16 return( 17 <View style={styles.container}> 18 <PhoneInput 19 ref={(ref) => { this.phone = ref; }} 20 onPressFlag={this.onPressFlag} 21 initialCountry={'us'} 22 initialValue="13178675309" 23 textProps={{ 24 placeholder: 'Enter a phone number...' 25 }} 26 /> 27 28 <ModalPickerImage 29 ref={(ref) => { this.myCountryPicker = ref; }} 30 data={this.state.pickerData} 31 onChange={(country)=>{ this.selectCountry(country) }} 32 cancelText='Cancel' 33 /> 34 </View> 35 ) 36}
see full custom picker example
We recommend using the awesome react-native-country-picker-modal to select country
(android/ios)
![]() | ![]() |
---|
1onPressFlag(){ 2 this.countryPicker.openModal() 3} 4 5selectCountry(country){ 6 this.phone.selectCountry(country.cca2.toLowerCase()) 7 this.setState({cca2: country.cca2}) 8} 9 10// Updates the Flag on change 11onPhoneInputChange = (value, iso2) => { 12 const newState = { 13 phoneInputValue: value, 14 }; 15 16 if (iso2) { 17 newState.countryCode = iso2?.toUpperCase(); 18 } 19 20 this.setState(newState); 21} 22 23render(){ 24 return( 25 <View style={styles.container}> 26 <PhoneInput 27 ref={(ref) => { this.phone = ref; }} 28 onPressFlag={this.onPressFlag} 29 initialCountry={'us'} 30 initialValue="13178675309" 31 onChangePhoneNumber={this.onPhoneInputChange} 32 textProps={{ 33 placeholder: 'Enter a phone number...' 34 }} 35 /> 36 37 <CountryPicker 38 ref={(ref) => { this.countryPicker = ref; }} 39 onChange={(value)=> this.selectCountry(value)} 40 translation='eng' 41 cca2={this.state.cca2} 42 > 43 <View></View> 44 </CountryPicker> 45 </View> 46 ) 47}
see full custom library picker example
If you need to change how the flag is rendered, you can use the renderFlag
property. This function is passed the flag image source as a named imageSource
argument.
Note: if you just need custom styles for the flag image, you can pass the
flagStyle
prop, only userenderFlag
if you need to change what components are actually rendered within the touchable area of the flag.
1<PhoneInput 2 renderFlag={({ imageSource }) => { 3 return ( 4 <View> 5 <Icon name="chevron" /> 6 <Image source={imageSource} width={customWidth} height={customHeight} style={customStyles} /> 7 </View> 8 ) 9 }} 10/>
1<PhoneInput countriesList={require('./countries.json')} />
Property Name | Type | Default | Description |
---|---|---|---|
autoFormat | boolean | false | Format phone number while typing |
accessibilityLabel | string | 'Telephone input' | Label for accessibility purposes |
initialCountry | string | 'us' | initial selected country |
allowZeroAfterCountryCode | bool | true | allow user input 0 after country code |
disabled | bool | false | if true, disable all interaction of this component |
initialValue | string | null | initial phone number |
style | object | null | custom styles to be applied if supplied |
flagStyle | object | null | custom styles for flag image eg. {{width: 50, height: 30, borderWidth:0}} |
textStyle | object | null | custom styles for phone number text input eg. {{fontSize: 14}} |
textProps | object | null | properties for phone number text input eg. {{placeholder: 'Telephone number'}} |
textComponent | function | TextField | the input component to use |
offset | int | 10 | distance between flag and phone number |
pickerButtonColor | string | '#007AFF' | set button color of country picker |
pickerBackgroundColor | string | 'white' | set background color of country picker |
pickerItemStyle | object | null | custom styles for text in country picker eg. {{fontSize: 14}} |
cancelText | string | 'Cancel' | cancel word |
confirmText | string | 'Confirm' | confirm word |
cancelTextStyle | object | null | custom styles for country picker cancel button |
confirmTextStyle | object | null | custom styles for country picker confirm button |
onChangePhoneNumber | function(number) | null | function to be invoked when phone number is changed |
onSelectCountry | function(iso2) | null | function to be invoked when country picker is selected |
onPressFlag | function() | null | function to be invoked when press on flag image |
renderFlag | function({ imageSource }) | null | custom render function for the flag component, passed an image src |
countriesList | array | null | custom countries list |
Function Name | Return Type | Parameters | Description |
---|---|---|---|
isValidNumber | boolean | none | return true if current phone number is valid |
getNumberType | string | none | return true type of current phone number |
getValue | string | none | return current phone number (unformatted) |
getFlag | object | iso2:string | return flag image |
getAllCountries | object | none | return country object in country picker |
getPickerData | object | nont | return country object with flag image |
focus | void | none | focus the phone input |
blur | void | none | blur the phone input |
selectCountry | void | iso2:string | set phone input to specific country |
setValue | void | string | set phone input value |
getCountryCode | string | none | return country dial code of current phone number |
getISOCode | string | none | return country iso code of current phone number |
onPressCancel | func | none | handler to be called when taps the cancel button |
onPressConfirm | func | none | handler to be called when taps the confirm button |
No vulnerabilities found.