Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jorisre/react-telephone

☎️ Tiniest react phone input component (auto formating included)
https://github.com/jorisre/react-telephone

phone phone-number phonenumber react reactjs

Last synced: 13 days ago
JSON representation

☎️ Tiniest react phone input component (auto formating included)

Awesome Lists containing this project

README

        

react-telephone - Demo






All Contributors




☎️ react-telephone


Tiniest react input phone component (auto formating included)




Demo
·
Documentation
·
Twitter
Created by Joris

## Features

- 🌐 Follows the **[E.164 : The international public telecommunication numbering plan](https://www.itu.int/rec/T-REC-E.164-201011-I/en)**
- 🎨 **Easily Customizable**
- 🪶 **Lightweight** - _less than 6kb_
- 📞 **Native** - _it's just a HMTL input_
- 🔌 **easily integration** - _it works without additional configuration (remix, react-hook-form)_
- [ ] Controlled mode: coming soon
- [ ] Custom render for `Phone.Country` and `Phone.Number`: coming soon

### Examples (Demo)

- [Basic](https://github.com/jorisre/react-telephone/blob/main/examples/src/components/samples/Basic.tsx)
- [Tailwind Css](https://github.com/jorisre/react-telephone/blob/main/examples/src/components/samples/Tailwind.tsx)
- [Styled Components](https://github.com/jorisre/react-telephone/blob/main/examples/src/components/samples/StyledComponents.tsx)
- [Css Modules](https://github.com/jorisre/react-telephone/blob/main/examples/src/components/samples/CssModules.tsx)
- [Inline Styles](https://github.com/jorisre/react-telephone/blob/main/examples/src/components/samples/InlineStyles.tsx)
- [React Hook Form](https://github.com/jorisre/react-telephone/blob/main/examples/src/components/samples/ReactHookForm.tsx)

## Installation

```sh
yarn add react-telephone
```

or

```sh
npm i react-telephone
```

## Usage

```tsx
import { Phone } from 'react-telephone';

export default function MyComponent() {
return (




);
}
```

## Props

| Prop | Description | Default | Value |
| :--------------- | :------------------------------------------------- | :---------------------------- | -----------------------------------------------------------------------: |
| `defaultCountry` | Default country displayed for the country selector | First country _(Afghanistan)_ | Country [ISO2 code](https://en.wikipedia.org/wiki/ISO_3166-2) _(fr, us)_ |

## Utils

| Name | Description |
| :----------------- | :------------------------------------------------- |
| `countries` | List of all countries. |
| `getCountryByIso` | Returns the country object for a given ISO code. |
| `applyMask` | Apply the mask to a given phone number. |
| `splitPhoneNumber` | Split a phone number into country code and number. |
| `replaceDialCode` | Replace the dial code of a phone number. |

## Contributors

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Joris
Joris

💻 📖 🤔 👀
Michaël Rézac
Michaël Rézac

🤔 💻
Varshneya Rao
Varshneya Rao

💻