Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mui-tel-input

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mui-tel-input

MUI tel input A phone number input designed for the React library MUI

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
68K
increased by11.81%
Maintainers
1
Weekly downloads
 
Created
Source

MUI tel input

A phone number input designed for the React library MUI

license ts npm CircleCI

➡️ ➡ ➡️ DEMO ⬅️ ⬅️ ⬅️

Installation

// with npm
npm install mui-tel-input

// with yarn
yarn add mui-tel-input

Usage

import React from 'react'
import { MuiTelInput } from 'mui-tel-input'

const MyComponent = () => {
  const [value, setValue] = React.useState('')

  const handleChange = (newValue) => {
    setValue(newValue)
  }

  return <MuiTelInput value={value} onChange={handleChange} />
}

Phone number validation

import React from 'react'
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'
import { MuiTelInput, isValidPhoneNumber } from 'mui-tel-input'

const MyComponent = () => {
  const [value, setValue] = React.useState('')
  const [isValid, setIsValid] = React.useState(false)

  const handleChange = (newValue) => {
    setIsValid(isValidPhoneNumber(newValue))
    setValue(newValue)
  }

  return (
    <Box>
      <Typography>This is valid ? {isValid ? 'yes' : 'no'}</Typography>
      <MuiTelInput value={value} onChange={handleChange} />
    </Box>
  )
}

Options

NameTypeDescription
valuestringThe phone number value (Required)
onChange?(value, info) => voidGets called once the user updates the input or selects a new country.
onlyCountries?arrayCountry codes to be included.
excludedCountries?arrayCountry codes to be excluded.
preferredCountries?arrayCountry codes to be highlighted to the top of the list of countries.
continents?arrayContinent codes to include a list of countries.
forceCallingCode?booleanForce the calling code (e.g: +33) to be displayed so the value cannot be empty. Default false.
focusOnSelectCountry?booleanAutofocus the input when the user selects a country in the list. Default false.
disableDropdown?booleanNo country list / The current flag is a span instead of a button. Default false.
disableFormatting?booleanRemove format (spaces..) from the input value. Default false.
langOfCountryName?stringAn Intl locale to translate countries (see Intl locales). Default en.
MenuProps?Menu APIProps for the Menu component.
ref?React.Ref<HTMLDivElement>A ref pointing to the Mui TextField component.
TextField Props

Inheritance

While not explicitly documented above, the props of the TextField component are also available on MuiTelInput.

Country code

A "country code" is a two-letter ISO country code (like US).

This library supports all officially assigned ISO alpha-2 country codes, plus a few extra ones like: AC (Ascension Island), TA (Tristan da Cunha), XK (Kosovo).

Continent code

CodeContinent
AFAfrica
ASAsia
EUEurope
NANorth America
OCOceania
SASouth America
OCOceania

TypeScript

This library comes with TypeScript "typings". If you happen to find any bugs in those, create an issue.

🐛 Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

💡 Feature Requests

Please file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on.

LICENSE

MIT

Keywords

FAQs

Package last updated on 01 Jun 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc