{"id":20630004,"url":"https://github.com/mackentoch/react-native-smooth-phone-input","last_synced_at":"2025-07-27T14:34:23.347Z","repository":{"id":34936083,"uuid":"158057186","full_name":"MacKentoch/react-native-smooth-phone-input","owner":"MacKentoch","description":"react-native user friendly phone input (users may not like country codes when typing their phone number 😉)","archived":false,"fork":false,"pushed_at":"2023-07-11T21:29:55.000Z","size":3469,"stargazers_count":14,"open_issues_count":6,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-11T12:50:21.331Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MacKentoch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-11-18T06:40:38.000Z","updated_at":"2024-07-23T13:34:11.000Z","dependencies_parsed_at":"2025-04-15T18:19:39.158Z","dependency_job_id":"43a27c56-fa05-4dde-a2c3-0e2d8737c015","html_url":"https://github.com/MacKentoch/react-native-smooth-phone-input","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/MacKentoch/react-native-smooth-phone-input","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacKentoch%2Freact-native-smooth-phone-input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacKentoch%2Freact-native-smooth-phone-input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacKentoch%2Freact-native-smooth-phone-input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacKentoch%2Freact-native-smooth-phone-input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MacKentoch","download_url":"https://codeload.github.com/MacKentoch/react-native-smooth-phone-input/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacKentoch%2Freact-native-smooth-phone-input/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267370869,"owners_count":24076497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T14:06:39.273Z","updated_at":"2025-07-27T14:34:23.298Z","avatar_url":"https://github.com/MacKentoch.png","language":"JavaScript","funding_links":["https://www.paypal.me/ErwanDatin/"],"categories":[],"sub_categories":[],"readme":"# react-native-smooth-phone-input\n\n\u003e react-native user friendly phone input (users may not like country codes when typing their phone number 😉)\n\n## What it does and does not\n\nIT:\n\n- follows national patterns (who write his own phone number in international pattern 🤨)\n- validates number\n- gives international matching number (*backend may prefer international pattern*)\n\nBUT IT:\n\n- does not make ☕️ (not planned to do so, sorry 😋)\n\n\u003cdiv style=\"position:relative;width:100vw;display:flex;flex-direction:row; flex-grow:1;background-color: #333333;padding:1rem 0.5rem;\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/MacKentoch/react-native-smooth-phone-input/master/assets/failed-1.png\" height=\"525px\"  width=\"250px\" alt=\"failed-1\" style=\"margin-right:0.5rem;border:solid 1px #333333 1px;border-radius:20px;\"/\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/MacKentoch/react-native-smooth-phone-input/master/assets/success-1.png\" height=\"525px\"  width=\"250px\" alt=\"success-1\" style=\"margin-right:0.5rem;border:solid 1px #333333;border-radius:20px;\" /\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/MacKentoch/react-native-smooth-phone-input/master/assets/failed-2.png\" height=\"525px\"  width=\"250px\" alt=\"failed-2\" style=\"margin-right:0.5rem;border:solid 1px #333333 ;border-radius:20px;\" /\u003e\n\u003c/div\u003e\n\n## Full use case\n\n```javascript\n// @flow\n\n// #region imports\nimport React, { PureComponent } from 'react';\nimport { View, StyleSheet, Dimensions, Text } from 'react-native';\nimport PhoneInput from 'react-native-smooth-phone-input';\nimport CountryPicker from 'react-native-country-picker-modal';\n// #endregion\n\n// #region flow types\nexport type Props = { ...any };\n\nexport type State = {\n  pickerData: Array\u003cany\u003e | null,\n  cca2?: string,\n  initialValue?: string,\n  initialCountry: 'fr' | 'us' | 'uk',\n  translation?: 'fra' | 'eng',\n  placeholder?: string,\n\n  isValidPhoneNumber: boolean,\n  countryCode: string,\n  isoCode: string,\n  intPhoneNum: string,\n\n  ...any,\n};\n// #endregion\n\n// #region constants\nconst { height: deviceHeight } = Dimensions.get('window');\n// #endregion\n\nclass Demo extends PureComponent\u003cProps, State\u003e {\n  // #region references\n  phone: any = null;\n  countryPicker: any = null;\n  // #endregion\n\n  state = {\n    cca2: '',\n    placeholder: '',\n    initialCountry: 'fr',\n    initialValue: null,\n    translation: 'fra',\n\n    isValidPhoneNumber: false,\n    countryCode: '',\n    isoCode: '',\n    intPhoneNum: '',\n  };\n\n  // #region lifecycle\n  componentDidMount() {\n    this.setState({ pickerData: this.phone.getPickerData() });\n  }\n\n  render() {\n    const {\n      cca2,\n      placeholder,\n      initialCountry,\n      initialValue,\n      translation,\n      isValidPhoneNumber,\n      countryCode,\n      isoCode,\n      intPhoneNum,\n    } = this.state;\n\n    const valueProps = !initialValue ? {} : { value: initialValue };\n\n    return (\n      \u003cView style={styles.container}\u003e\n        \u003cView style={styles.phoneForm}\u003e\n          {/* phone input: */}\n          \u003cPhoneInput\n            ref={this.setPhoneRef}\n            style={{\n              height: 50,\n              backgroundColor: '#FFFFFF',\n              paddingHorizontal: 10,\n              borderColor: '#EEEEEE',\n              borderWidth: 1,\n              borderRadius: 1,\n            }}\n            onPressFlag={this.onPressFlag}\n            initialCountry={initialCountry.toLowerCase()}\n            autoFormat\n            textProps={{\n              placeholder,\n              keyboardType: 'phone-pad',\n              textContentType: 'telephoneNumber',\n            }}\n            {...valueProps}\n            onChangePhoneNumber={this.handlesOnInputChange}\n          \u003e\n            {cca2}\n          \u003c/PhoneInput\u003e\n          \u003cView style={styles.statusContainer}\u003e\n            \u003cText\u003e\n              Phone number is valid:{' '}\n              {!isValidPhoneNumber ? 'NOT A VALID NUMBER' : 'VALID!'}\n            \u003c/Text\u003e\n            \u003cText\u003ecountry code: {countryCode || ''}\u003c/Text\u003e\n            \u003cText\u003eiso code: {isoCode || ''}\u003c/Text\u003e\n            \u003cText\u003einternational phone number: {intPhoneNum || ''}\u003c/Text\u003e\n          \u003c/View\u003e\n\n          {/* country picker modal: */}\n          \u003cCountryPicker\n            ref={this.setCountryPicker}\n            onChange={this.handlesOnSelectCountry}\n            translation={translation}\n            cca2={cca2 || 'fr'}\n            filterable\n            filterPlaceholder={'Select a country'}\n            closeable\n            transparent\n            autoFocusFilter\n            styles={countryPickerStyle}\n          \u003e\n            \u003cView /\u003e\n          \u003c/CountryPicker\u003e\n        \u003c/View\u003e\n      \u003c/View\u003e\n    );\n  }\n  // #endregion\n\n  // #region phone input related\n\n  // #region set phone input reference\n  setPhoneRef = (ref: any) =\u003e (this.phone = ref);\n  // #endregion\n\n  // #region on press flag (open country  modal)\n  onPressFlag = () =\u003e this.countryPicker.openModal();\n  // #endregion\n\n  // #region on input change event\n  handlesOnInputChange = (value: string) =\u003e {\n    this.setState({\n      cca2: value,\n      isValidPhoneNumber: this.phone.isValid(),\n      countryCode: this.phone.getCountryCode(),\n      isoCode: this.phone.getISOCode(),\n      intPhoneNum: this.phone.getInternationalFormatted(),\n    });\n\n    const payload = {\n      phone: this.phone.getInternationalFormatted(),\n      isValidNumber: this.phone.isValid(),\n      isoCode: this.phone.getISOCode(),\n      countryCode: this.phone.getCountryCode(),\n    };\n\n    console.log('handlesOnInputChange: payload: ', payload);\n  };\n  // #endregion\n\n  // #endregion\n\n  // #region country picker related\n\n  // #region set countryPicker reference\n  setCountryPicker = (ref: any) =\u003e (this.countryPicker = ref);\n  // #endregion\n\n  // #region on country selection\n  handlesOnSelectCountry = ({ cca2 }: { cca2: string }) =\u003e {\n    this.phone.selectCountry(cca2.toLowerCase());\n    this.setState({ cca2: cca2 });\n  };\n  // #endregion\n\n  // #endregion\n}\n\n// #region styles\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n  },\n  phoneForm: {\n    marginTop: (deviceHeight * 1) / 5,\n    flex: 1,\n    paddingHorizontal: 10,\n  },\n  statusContainer: {\n    marginVertical: 20,\n  },\n});\n\nconst countryPickerStyle = StyleSheet.create({\n  itemCountryName: {\n    borderBottomWidth: 0,\n    borderBottomColor: 'transparent',\n  },\n  countryName: {\n    color: '#4A4A4A',\n    borderColor: 'transparent',\n    fontSize: 15,\n  },\n  letterText: {\n    color: '#4A4A4A',\n    borderColor: 'transparent',\n  },\n  input: {\n    color: '#4A4A4A',\n    borderBottomWidth: 1,\n    fontSize: 15,\n    borderColor: '#4A4A4A',\n  },\n  closeButton: {\n    height: 56,\n    padding: 10,\n    width: '15%',\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n  closeButtonImage: {\n    height: 32,\n    width: 32,\n  },\n});\n// #endregion\n\nexport default Demo;\n```\n\n\n## Donate\n\nDo you use \u0026 like `react-native-smooth-phone-input` but you don’t find a way to show some ❤️?\nIf yes, please consider donating to support this project. Otherwise, no worries, regardless of whether there is support or not, I will keep maintaining this project. Still, if you buy me a cup of coffee I would be more than happy though 😄\n\n[![Support via PayPal](https://raw.githubusercontent.com/MacKentoch/react-native-smooth-phone-input/master/assets/Paypal-button.png)](https://www.paypal.me/ErwanDatin/)\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2019 Erwan DATIN\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmackentoch%2Freact-native-smooth-phone-input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmackentoch%2Freact-native-smooth-phone-input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmackentoch%2Freact-native-smooth-phone-input/lists"}