Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/andria-dev/mui-phone-input

A phone number input built with material-ui's TextField
https://github.com/andria-dev/mui-phone-input

Last synced: 23 days ago
JSON representation

A phone number input built with material-ui's TextField

Awesome Lists containing this project

README

        

# mui-phone-input

This is a simple wrapper around material-ui's `` component. This wrapper handles the input as a phone number. It only allows numbers, and dashes are automatically inserted and removed while typing.

Here is what the input looks like while typing:

![GIF of typing numbers into input](mui-phone-input.gif)

# Install

```bash
npm i mui-phone-input
# or
yarn add mui-phone-input
```

# Usage with React

All properties available to [material-ui's ``](https://material-ui.com/api/text-field/) are available to ``.

Here is a minimal example of using the input:

```jsx
import React from 'react';
import PhoneInput from 'mui-phone-input';

function App() {
const [value, setValue] = React.useState('');
return (



Your phone number is {value}



);
}
```

### Notes:

- 90% of the time, you won't need to use two-way data binding. This is due to the fact that this input formats everything for you.
- However, two-way data binding is still available.