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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xsolla/xui-input-phone

v0.134.0

Published

A cross-platform React phone number input component with integrated country selector. Features a searchable country dropdown with flags and dial codes.

Downloads

4,086

Readme

Input Phone

A cross-platform React phone number input component with integrated country selector. Features a searchable country dropdown with flags and dial codes.

Installation

npm install @xsolla/xui-input-phone
# or
yarn add @xsolla/xui-input-phone

Demo

Basic Phone Input

import * as React from 'react';
import { InputPhone } from '@xsolla/xui-input-phone';

export default function BasicPhoneInput() {
  const [phone, setPhone] = React.useState('');

  return (
    <InputPhone
      value={phone}
      onChange={(e) => setPhone(e.target.value)}
      placeholder="+1 (000) 000-0000"
    />
  );
}

With Country Selection

import * as React from 'react';
import { InputPhone, Country } from '@xsolla/xui-input-phone';

export default function CountryPhoneInput() {
  const [phone, setPhone] = React.useState('');
  const [country, setCountry] = React.useState<Country | undefined>();

  return (
    <InputPhone
      value={phone}
      onChange={(e) => setPhone(e.target.value)}
      selectedCountry={country}
      onCountryChange={setCountry}
    />
  );
}

With Validation

import * as React from 'react';
import { InputPhone } from '@xsolla/xui-input-phone';

export default function ValidatedPhoneInput() {
  const [phone, setPhone] = React.useState('');
  const isValid = phone.length >= 10;

  return (
    <InputPhone
      value={phone}
      onChange={(e) => setPhone(e.target.value)}
      checked={isValid}
      extraClear={true}
      onRemove={() => setPhone('')}
    />
  );
}

Anatomy

import { InputPhone } from '@xsolla/xui-input-phone';

<InputPhone
  value={phoneNumber}            // Phone number value
  onChange={handleChange}        // Change event handler
  selectedCountry={country}      // Currently selected country
  onCountryChange={setCountry}   // Country selection handler
  countries={customCountries}    // Custom countries array
  placeholder="+1 (000) 000-0000" // Placeholder text
  size="md"                       // Size variant
  disabled={false}               // Disabled state
  error={false}                  // Error state
  errorMessage="Error"           // Error message
  extraClear={false}             // Show clear button
  onRemove={handleClear}         // Clear button handler
  checked={false}                // Show validation checkmark
/>

Examples

Error State

import * as React from 'react';
import { InputPhone } from '@xsolla/xui-input-phone';

export default function ErrorPhoneInput() {
  return (
    <InputPhone
      value="123"
      error={true}
      errorMessage="Please enter a valid phone number"
    />
  );
}

Phone Input Sizes

import * as React from 'react';
import { InputPhone } from '@xsolla/xui-input-phone';

export default function PhoneInputSizes() {
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
      <InputPhone size="xs" placeholder="Extra Small" />
      <InputPhone size="sm" placeholder="Small" />
      <InputPhone size="md" placeholder="Medium" />
      <InputPhone size="lg" placeholder="Large" />
      <InputPhone size="xl" placeholder="Extra Large" />
    </div>
  );
}

Custom Countries

import * as React from 'react';
import { InputPhone, Country } from '@xsolla/xui-input-phone';

export default function CustomCountriesPhone() {
  const [phone, setPhone] = React.useState('');

  const countries: Country[] = [
    { code: 'US', name: 'United States', dialCode: '+1' },
    { code: 'GB', name: 'United Kingdom', dialCode: '+44' },
    { code: 'DE', name: 'Germany', dialCode: '+49' },
  ];

  return (
    <InputPhone
      value={phone}
      onChange={(e) => setPhone(e.target.value)}
      countries={countries}
    />
  );
}

API Reference

InputPhone

InputPhone Props:

| Prop | Type | Default | Description | | :--- | :--- | :------ | :---------- | | value | string | - | Phone number value. | | onChange | (e: ChangeEvent) => void | - | Change event handler. | | onChangeText | (text: string) => void | - | Text change handler. | | countries | Country[] | All countries | Available countries for selection. | | selectedCountry | Country | - | Currently selected country. | | onCountryChange | (country: Country) => void | - | Country selection handler. | | placeholder | string | "+1 (000) 000-0000" | Placeholder text. | | size | "xl" \| "lg" \| "md" \| "sm" \| "xs" | "md" | Component size. | | disabled | boolean | false | Disabled state. | | error | boolean | false | Error state. | | errorMessage | string | - | Error message text. | | extraClear | boolean | false | Show clear button. | | onRemove | () => void | - | Clear button handler. | | checked | boolean | false | Show validation checkmark. | | checkedIcon | ReactNode | Check icon | Custom checkmark icon. | | testID | string | - | Test identifier. |

Country Interface:

interface Country {
  code: string;      // ISO 3166-1 alpha-2 (e.g., "US")
  name: string;      // Country name
  dialCode: string;  // International dial code (e.g., "+1")
  flag?: ReactNode;  // Optional flag icon
}

Keyboard Navigation

| Key | Action | | :-- | :----- | | Arrow Down | Open dropdown / Next country | | Arrow Up | Previous country | | Enter | Select country / Open dropdown | | Escape | Close dropdown |

Accessibility

  • Country selector uses role="combobox"
  • Country list uses role="listbox" with role="option" items
  • Searchable dropdown with aria-controls linking
  • Phone input uses type="tel" and inputMode="tel"