npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-phone-entry

v0.2.4

Published

Simple and fully modifiable Phone Number Input Component for React Native

Readme

react-native-phone-entry

npm version License

react-native-phone-entry is a simple and fully modifiable Phone Number Input Component for React Native that provides an intuitive interface for entering and validating international phone numbers. It includes country code selection, number formatting, and validation features.

Looking for an OTP input component to verify phone numbers? Check out react-native-otp-entry - a simple and fully modifiable OTP Input Component for React Native that provides an intuitive interface for entering one-time passwords.

Features

  • 🌍 International phone number input with country picker
  • 📱 Automatic phone number formatting based on country
  • 🔍 Dynamic country and mask adaptation based on typed country code
  • ✨ Highly customizable appearance and styling
  • 🎯 Phone number validation using Google's libphonenumber
  • 🎨 Dark theme support
  • ♿ Accessibility support
  • 💪 Written in TypeScript

Installation

npm install react-native-phone-entry

# or

yarn add react-native-phone-entry

Usage

  1. Import the PhoneInput component:
import { PhoneInput, isValidNumber } from 'react-native-phone-entry';
  1. Basic usage:
export default function App() {
  const [countryCode, setCountryCode] = useState < CountryCode > 'US';
  return (
    <PhoneInput
      defaultValues={{
        countryCode: 'US',
        callingCode: '+1',
        phoneNumber: '+1',
      }}
      onChangeText={(text) =>
        console.log(
          'Phone number:',
          text,
          'isValidNumber:',
          isValidNumber(text, countryCode)
        )
      }
      onChangeCountry={(country) => {
        console.log('Country:', country);
        setCountryCode(country.cca2);
      }}
    />
  );
}
  1. Advanced usage with customization:
<PhoneInput
  defaultValues={{
    countryCode: 'US',
    callingCode: '+1',
    phoneNumber: '+123456789',
  }}
  value="+123456789"
  onChangeText={(text) => console.log('Phone number:', text)}
  onChangeCountry={(country) => console.log('Country:', country)}
  autoFocus={true}
  disabled={false}
  countryPickerProps={{
    withFilter: true,
    withFlag: true,
    withCountryNameButton: true,
  }}
  theme={{
    containerStyle: styles.phoneContainer,
    textInputStyle: styles.input,
    flagButtonStyle: styles.flagButton,
    codeTextStyle: styles.codeText,
    dropDownImageStyle: styles.dropDownImage,
    enableDarkTheme: false,
  }}
  hideDropdownIcon={false}
  isCallingCodeEditable={false}
/>

Props

| Prop | Type | Description | Default | | ----------------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | ----------- | | defaultValues | object | Default values for country code, calling code, and phone number | undefined | | value | string | Controlled value for the phone number input | undefined | | onChangeText | (text: string) => void | Callback when phone number changes | undefined | | onChangeCountry | (country: Country) => void | Callback when selected country changes | undefined | | autoFocus | boolean | Automatically focuses the input when mounted | false | | disabled | boolean | Disables the input | false | | countryPickerProps | CountryPickerProps | Props for the country picker modal | {} | | maskInputProps | MaskInputProps | Props for the masked input component | {} | | theme | Theme | Theme configuration for styling the component | {} | | hideDropdownIcon | boolean | Hides the dropdown arrow icon when set to true | false | | renderCustomDropdown | ReactNode | Custom component to replace the default dropdown arrow | undefined | | flagProps | object | Props for customizing the country flag | {} | | dropDownImageProps | ImageProps | Props for customizing the dropdown arrow image | {} | | isCallingCodeEditable | boolean | Controls whether the calling code can be edited | true |

Theme Properties

| Property | Type | Description | Default | | -------------------- | ------------------------------------------------------------------------- | ------------------------------------ | ----------- | | containerStyle | StyleProp<ViewStyle> | Style for the main container | undefined | | textInputStyle | StyleProp<TextStyle> | Style for the text input | undefined | | codeTextStyle | StyleProp<TextStyle> | Style for the calling code text | undefined | | flagButtonStyle | StyleProp<ViewStyle> | Style for the flag button | undefined | | dropDownImageStyle | StyleProp<ImageStyle> | Style for the dropdown arrow image | undefined | | enableDarkTheme | boolean | Enables dark theme for the component | false |

Utility Functions

isValidNumber(phoneNumber: string, countryCode: string): boolean

Validates a phone number for a specific country using Google's libphonenumber.

import { isValidNumber } from 'react-native-phone-entry';

const isValid = isValidNumber('+1234567890', 'US');

Dependencies

This library depends on the following packages:

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

TODO

  • [ ] Expose ref of the input
  • [ ] Add custom country picker modal

License

This project is licensed under the MIT License.


Made with create-react-native-library

Inspired by react-native-phone-number-input