rpi

react-phone-input

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

Showing:

Popularity

Downloads/wk

454

GitHub Stars

86

Maintenance

Last Commit

4yrs ago

Contributors

15

Package

Dependencies

1

Size (min+gzip)

142.7KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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:

import ReactPhoneInput from 'react-phone-input';

React.render(  
  <ReactPhoneInput defaultCountry={'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:

function handeOnChange(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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100