Socket
Socket
Sign inDemoInstall

material-ui-phone-number

Package Overview
Dependencies
40
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    material-ui-phone-number

A material-ui react component to format phone numbers. Based on react-phone-input-2


Version published
Maintainers
1
Install size
346 kB
Created

Changelog

Source

[2.0.1] - 2019-07-17

Fixed

  • Changed the phone number format for Sweden
  • Update lodash for security vulnerability
  • Removed reliance on theme providers

Readme

Source

material-ui-phone-number

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:

alt tag

Uses @material-ui/core/TextField for rendering the phone input

Installation

npm install material-ui-phone-number --save

Usage

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

Name Type Description Example
excludeCountries array array of country codes to be excluded ['cu','cw','kz']
onlyCountries array country codes to be included ['cu','cw','kz']
preferredCountries array country codes to be at the top ['cu','cw','kz']
defaultCountry string initial country 'us'
inputClass string class for input
dropdownClass string class for dropdown container
autoFormat bool on/off auto formatting, true by default
disableAreaCodes bool disable local codes for all countries
disableCountryCode bool false by default
disableDropdown bool false by default
enableLongNumbers bool false by default
countryCodeEditable bool true by default
Supported TextField props
value string input state value
placeholder string placeholder for the TextField input
label string | element label for the TextField
name string input name
required bool false by default
disabled bool disable input and dropdown
helperText string TextField helper text
inputProps object props that get spread to TextField InputProps
inputRef function callback for getting the input reference
autoFocus bool autoFocus input
error boolean TextField error state
variant string 'standard' by default
fullWidth boolean TextField property - false by default

Regions

Name Type Description
regions array/string to only show codes from selected regions
Regions
['america', 'europe', 'asia', 'oceania', 'africa']
Subregions
['north-america', 'south-america', 'central-america', 'carribean', 'european-union', 'ex-ussr', 'middle-east', 'north-africa']

Regions selected: {'europe'}

<MuiPhoneInput
  defaultCountry='it'
  regions={'europe'}
/>

Regions selected: {['north-america', 'carribean']}

<MuiPhoneInput
  defaultCountry='ca'
  regions={['north-america', 'carribean']}
/>

Localization

Name Type
localization object
<MuiPhoneInput
  onlyCountries=['de', 'es']
  localization={{'Germany': 'Deutschland', 'Spain': 'España'}}
/>

Supported events

onChange onFocus onBlur onClick onKeyDown

Country data object not returns from onKeyDown event

Data Type Description
value/event string/object the event or the phone number
country data object the country object { name, dialCode, country code (iso2 format) }

License

Based on react-phone-input-2

Based on react-phone-input using MIT

Keywords

FAQs

Last updated on 17 Jul 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc