dyxbenjamin-mui-phone-number
v2.0.3
Published
A material-ui react component to format phone numbers. Based on react-phone-input-2
Downloads
67
Maintainers
Readme
@DyxBenjamin/mui-phone-number
This repository is a fork of material-ui-phone-number repository. To fix different issues.
Highly customizable phone input component with auto formatting. Based on the wonderful react-phone-input-2 package.
It looks like this, but in Material Design:
Uses @material-ui/core/TextField for rendering the phone input
Installation
npm i dyxbenjamin-mui-phone-number
Usage
import MuiPhoneNumber from 'material-ui-phone-number';
React.render(
<MuiPhoneNumber defaultCountry={'us'} onChange={handleOnChange}/>,
document.getElementById('root')
);
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 handleOnChange(value) {
this.setState({
phone: value
});
}
Options
Regions
Regions selected: {'europe'}
<MuiPhoneInput
defaultCountry='it'
regions={'europe'}
/>
Regions selected: {['north-america', 'carribean']}
<MuiPhoneInput
defaultCountry='ca'
regions={['north-america', 'carribean']}
/>
Localization
<MuiPhoneInput
onlyCountries=['de', 'es']
localization={{'Germany': 'Deutschland', 'Spain': 'España'}}
/>
Supported events
Country data object not returns from onKeyDown event
License
Based on react-phone-input-2
Based on react-phone-input using MIT