A React hook for building phone number inputs

Overview

use-telephone

A React hook for building phone number inputs

Installation

use-telephone depends on React >= 16.8, so make sure you have it installed.

yarn add use-telephone react

Usage

import {useTelephone, countries} from 'use-telephone';

export default function App() {
	const telephone = useTelephone();

	return (
		<>
			<select value={telephone.country} onChange={e => telephone.onChangeCountry(e.target.value)}>
				{countries.map(country => {
					return (
						<option key={country.value} value={country.value}>
							{country.label}
						</option>
					);
				})}
			</select>

			<img src={telephone.flag} alt="Flag of the current selected country" />

			<input placeholder="(xxx) xxx-xxxx" value={telephone.value} onChange={telephone.onChange} />
		</>
	);
}
You might also like...
Input mask for React, Angular, Ember, Vue, & plain JavaScript
Input mask for React, Angular, Ember, Vue, & plain JavaScript

Text Mask is an input mask library. It can create input masks for phone, date, currency, zip code, percentage, email, and literally anything!

React component for entering and validating PIN code.
React component for entering and validating PIN code.

React component for entering and validating PIN code.

An input of type password implemented with React and TypeScript

An input of type password implemented with React and TypeScript

Numeric input control with step buttons for Semantic UI React
Numeric input control with step buttons for Semantic UI React

Numeric input control with step buttons for Semantic UI React

React Currency Input Field Component
React Currency Input Field Component

React Currency Input Field Component

React Individual Character Input Boxes
React Individual Character Input Boxes

react-individual-character-input-boxes React Individual Character Input Boxes (RICIBs) are individual inputs that are separate from each other but fun

A fully customizable, one-time password input component for the web built with React.
A fully customizable, one-time password input component for the web built with React.

react-otp-input A fully customizable, one-time password input component for the web built with React. Live Demo CodeSandbox Installation To install th

A React component that decorates it's children with mouse/touch position tracking, a status toggle fired by click/gesture events, and more.

A React component that decorates it's children with mouse/touch position tracking, a status toggle fired by click/gesture events, and more.

React component that handles csv file input and its parsing

react-csv-reader React component that handles csv file input. It handles file input and returns its content as a matrix. Docs: nzambello.github.io/rea

Owner
Alistair Smith
barcode blaster
Alistair Smith
React Input Format & Mask, tiny (≈800b) component to transform any input component into formatted or masked input. Supports number, date, phone, currency, credit card, etc

RIFM - React Input Format & Mask Is a tiny (≈ 800b) component (and hook) to transform any input component into formatted or masked input. Demo Highlig

RealAdvisor 1.3k Dec 13, 2022
React component for international phone number input

react-phone-number-input International phone number input for React. See Demo Install npm install react-phone-number-input --save If you're not us

Nikolay 837 Dec 21, 2022
International phone number input component for react

Welcome to react-contact-number-input ?? International phone number input component for react Install npm install react-contact-number-input Author ??

Vaibhav Gurnani 15 Nov 9, 2022
A react component for digit inputs

A react component for digit inputs. It might be very useful to get SMS codes from user on two factor authentications and in many other scenarios when you need get an numerical input from user digit by digit.

Yusuf Yalım 11 Sep 7, 2022
A numpad for number, date and time, built with and for React.

React numpad A numpad for number, date and time, built with and for React. It's written with the extensibility in mind. The idea of this project is to

Pietro Ghezzi 130 Dec 21, 2022
React Input Number

rc-input-number Input number control.

react-component 275 Dec 13, 2022
A React Hook & Container to help with payment card input fields.

React Payment Inputs A React Hook & Container to help with payment card input fields. React Payment Inputs Demos Requirements Installation Usage With

medipass 303 Dec 22, 2022
Input masking component for React. Made with attention to UX.

react-input-mask Input masking component for React. Made with attention to UX. This is a development branch for version 3.0. For the latest stable ver

Nikita Lobachev 2.1k Dec 30, 2022
Masked input React component

MaskedInput A React component for input masking, built on top of inputmask-core. Live Demo Install npm npm install react-maskedinput --save Browser

Jonny Buchanan 721 Nov 30, 2022
Input mask for React, Angular, Ember, Vue, & plain JavaScript

⚠️ This library is not maintained. Pull-requests and issues are not monitored. Alternatives to text-mask include: https://github.com/uNmAnNeR/imaskjs

Text Mask 8.2k Jan 2, 2023