[go: up one dir, main page]

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

1.0.29 • Public • Published

react-number-formatter

This React input component automatically formats phone numbers as you type and returns the actual number you entered. 😊

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

Demo with hook form

Normal 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.

<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

12

Version

1.0.29

License

MIT

Unpacked Size

159 kB

Total Files

232

Last publish

Collaborators

  • faraz.khan