Gathering detailed insights and metrics for react-telephone-input
Gathering detailed insights and metrics for react-telephone-input
Gathering detailed insights and metrics for react-telephone-input
Gathering detailed insights and metrics for react-telephone-input
react-phone-number-input
Telephone number input React component
react-phone-input-2
A react component to format phone numbers
intl-tel-input
A JavaScript plugin for entering and validating international telephone numbers
react-international-phone
☎️ International phone input component for React
React component for entering and validating international telephone numbers
npm install react-telephone-input
Typescript
Module System
Node Version
NPM Version
90
Supply Chain
98.2
Quality
74.7
Maintenance
100
Vulnerability
99.3
License
Less (32.65%)
TypeScript (26.64%)
JavaScript (20.59%)
CSS (19.34%)
HTML (0.78%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
266 Stars
427 Commits
166 Forks
7 Watchers
22 Branches
25 Contributors
Updated on Aug 12, 2024
Latest Version
5.0.0
Package Id
react-telephone-input@5.0.0
Size
61.14 kB
NPM Version
6.14.4
Node Version
14.0.0
Published on
May 02, 2020
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
11
1
31
IMP: From 5.*, the withStyles file will not be bundled in dist. If you want to use the css, you can import the css file directly to your module -
1import 'react-telephone-input/css/default.css'
IMP: From 3.*, the styles won't be included by default. Can use require('react-telephone-input/lib/withStyles')
to get the styles.
Inspired from the awesome jquery plugin for International Telephone Input.
This one is written as a reactjs component.
Live Demo here - http://unstack.in/react-telephone-input/
1function handleInputChange(telNumber, selectedCountry) { 2 console.log('input changed. number: ', telNumber, 'selected country: ', selectedCountry); 3} 4 5// Use declaratively within another react components render method 6var ReactTelInput = require('react-telephone-input'); 7// var ReactTelInput = require('react-telephone-input/lib/withStyles'), if you need the styles 8 9<MyAwesomeReactComponent> 10 <ReactTelInput 11 defaultCountry="in" 12 flagsImagePath='/path/to/images/flags.png' 13 onChange={handleInputChange} 14 onBlur={handleInputBlur} 15 /> 16</MyAwesomeReactComponent> 17 18// or render standalone 19var ReactTelInput = require('react-telephone-input'); 20React.render(<ReactTelInput 21 defaultCountry="in" 22 flagsImagePath='/path/to/images/flags.png' 23 onChange={handleInputChange} 24 onBlur={handleInputBlur} 25 />, 26 document.getElementById('my-container'));
The component accepts other props to customize it -
Both the props have the same purpose - for setting the initial value of the input programatically.
See value
above.
true
by default. Setting it to false will turn off all auto formatting.
The component selects the country code of a country by default. You can change it by passing the iso2 name of a country. E.g. for United States, set defaultCountry
to 'us'.
If you don't want all countries to be shown in the dropdown list, you can pass an array of objects representing the countries. The structure of each country object can be seen here https://github.com/mukeshsoni/country-telephone-data/blob/master/country_telephone_data.js
E.g.
<ReactTelInput
defaultCountry='us'
value={value}
onChange={onPhoneChange}
onlyCountries={[
{name: "United States", iso2: "us", dialCode: "1", priority: 0, format: "+. (...) ...-...."},
{name: "Canada", iso2: "ca", dialCode: "1", priority: 1, format: "+. (...) ...-....", hasAreaCodes: true},
{name: "Mexico (México)", iso2: "mx", dialCode: "52", priority: 0, format: "+..-..-..-...."},
{name: "Brazil (Brasil)", iso2: "br", dialCode: "55", priority: 0, format: "+..-..-....-...."},
]}
/>
Preferred countries show up at the top of the list. This prop also accepts an array of country iso2 names.
E.g.
<ReactTelephoneInput
preferredCountries={['in', 'us', 'gb']}
/>
You can send in additional classes to be applied to the top container div of the component.
Function, which is called whenever there is a change of value in the input box.
Function, which is called when user presses the 'enter' key when the input box is in focus.
Function, which is called when the focus goes away from the input box.
Function, which is called when the input box gets the focus.
Boolean value. When set to true, the input box is disabled and clicking on flag dropdown does nothing.
String. This is passed on to the input field and works like it should for any other input field.
Object. If you want to set some property on the input element, you can pass in an object with attributes. E.g.
1let inputProps={ 2 readOnly: true, 3 autoFocus: true 4} 5 6<ReactTelephoneInput inputProps={inputProps} ... />
string. Specify the type of autocomplete for the input element.
Default value - 'tel'
Object. Style applied to the dropdown list container. There is a default value for it
listStyle = {
zIndex: 20,
backgroundColor: 'white'
}
string. Classname which will be applied to each item in the dropdown list. The default is country
npm install
, you can just do var ReactTelephoneInput = require('react-telephone-input');
flagsImagePath
1function handleInputChange(telNumber, selectedCountry) { 2 console.log('input changed. number: ', telNumber, 'selected country: ', selectedCountry) 3} 4 5function handleInputBlur(telNumber, selectedCountry) { 6 console.log( 7 'Focus off the ReactTelephoneInput component. Tel number entered is: ', 8 telNumber, 9 ' selected country is: ', 10 selectedCountry 11 ) 12} 13 14<ReactTelephoneInput 15 defaultCountry="in" 16 flagsImagePath="/path/to/images/flags.png" 17 onChange={handleInputChange} 18 onBlur={handleInputBlur} 19/>
The default value for flagsImagePath
is 'flags.png'
You can try the app by downloading everything and running the commands given below -
$ npm install
$ npm start
go to your browser and type http://localhost:3000
$ npm run test
$ npm run test -- --watch # to run tests in watch mode
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/19 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
131 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More