Skip to content

Repository files navigation

react-phone-input

A simple react component to format a phone number as the user types.

alt tag

Installation:

npm install react-phone-input --save

Usage:

importReactPhoneInputfrom'react-phone-input';React.render(<ReactPhoneInputdefaultCountry={'us'}onChange={handleOnChange)/>,document.getElementById('content'));

Your handler for the onChange event should expect a string as parameter, where the value is that of the entered phone number. For example:

functionhandeOnChange(value){this.setState({phone: value});}

Options:

NameDescription
defaultCountrycountry code to initialize the component
excludeCountriesarray of country codes to be excluded e.g. ['cu','cw','kz']
onlyCountriesarray of country codes to be included e.g. ['cu','cw','kz']
preferredCountriesarray of country codes to be preferred (highlighted at the top) e.g. ['cu','cw','kz']

License

MIT

About

A simple react component to format phone number as the user types

Resources

Stars

87 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages