react-number-formatter
TypeScript icon, indicating that this package has built-in type declarations

1.0.20 • Public • Published

react-number-formatter

This react input component automatically formats phone numbers inside input and returns the number you actually typed.

Installation

Run this command in your terminal

npm add react-number-formatter
Props Description
getCountryCode To get selected country code
format To create your own format
defaultCountry To make a country default selected
onlyCountries To filter country options
fixLength To limit input length
disabled To make input and selector disable
fullIsoCode Sets 3 letter ISO Code e.g. "IND", "USA"
searchOption To add or remove search bar
register To use this input inside react-hook-form
flags: Boolean To get country code instead of flag
placeholder: String To change placeholder
initialFormat: Boolean When using this component in editable forms. this function automatically guess the the dial code and formats the number

Usage

import { NumberFormatter } from 'react-number-formatter';
const [number, setNumber] = useState();
//for typescript
const [number, setNumber] = useState<string | number>();

Screenshot 2023-05-14 at 1 55 15 PM

<NumberFormatter
  value={number}
  initialFormat={true}
  getValue={(n: string) => setNumber(n)}
/> 

Screen Recording 2023-05-14 at 2 03 26 PM

You can create your own format too.

<NumberFormatter
  format={"+1 (###)-(###)-####"}
  value={number}
  getValue={(n: string) => setNumber(n)}
/> 

Screen_Recording_2023-02-19_at_8_03_19_PM_AdobeExpress

Package Sidebar

Install

npm i react-number-formatter

Weekly Downloads

72

Version

1.0.20

License

MIT

Unpacked Size

98.6 kB

Total Files

17

Last publish

Collaborators

  • faraz.khan