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

ngx-phone-country-input

v1.6.0

Published

A comprehensive Angular library providing phone input and country selection components with full reactive forms support.

Readme

NgxPhoneCountryInput Library

A comprehensive Angular library providing phone input and country selection components with full reactive forms support.

Components

1. NgxPhoneInput

A complete phone number input with integrated country selection.

2. NgxCountrySelect

A standalone country selector with search functionality and reactive forms support.

Features

  • 🌍 200+ Countries: Complete list with flags and dial codes
  • 🔍 Search Functionality: Quick country lookup
  • 📱 Responsive Design: Works on mobile and desktop
  • Accessible: Full keyboard navigation and screen reader support
  • 🎨 Customizable: Multiple configuration options
  • 📋 Reactive Forms: Full Angular Forms integration with ControlValueAccessor
  • 🎯 TypeScript: Full type safety

Installation

# Install the library
npm install ngx-phone-country-input

Basic Usage

Standalone Phone Input

import { NgxPhoneInput } from "ngx-phone-country-input";

@Component({
  imports: [NgxPhoneInput],
  template: `
    <ngx-phone-input
      placeholder="Enter phone number"
      [defaultCountry]="'US'"
      (valueChange)="onPhoneChange($event)"
    />
  `,
})
export class MyComponent {
  onPhoneChange(value: PhoneInputValue) {
    console.log("Phone:", value.fullNumber);
    console.log("Valid:", value.isValid);
  }
}

Standalone Country Select

import { NgxCountrySelect } from "ngx-phone-country-input";

@Component({
  imports: [NgxCountrySelect],
  template: `
    <ngx-country-select
      placeholder="Select country"
      [preferredCountries]="['US', 'GB', 'CA']"
      (countryChange)="onCountryChange($event)"
    />
  `,
})
export class MyComponent {
  onCountryChange(country: CountryModel) {
    console.log("Selected:", country.name);
  }
}

Reactive Forms Integration

import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
import { NgxCountrySelect } from "ngx-phone-country-input";

@Component({
  imports: [ReactiveFormsModule, NgxCountrySelect],
  template: `
    <form [formGroup]="userForm">
      <ngx-country-select
        formControlName="country"
        placeholder="Select your country"
      />

      <button [disabled]="userForm.invalid">Submit</button>
    </form>
  `,
})
export class MyComponent {
  userForm = this.fb.group({
    country: ["US", Validators.required],
  });

  constructor(private fb: FormBuilder) {}
}

Component APIs

NgxPhoneInput

Inputs

  • placeholder: string - Input placeholder text
  • disabled: boolean - Disable the component
  • defaultCountry: string - Initial country (ISO2 code)
  • preferredCountries: string[] - Countries to show at top
  • showFlags: boolean - Show country flags (default: true)
  • showDialCode: boolean - Show dial codes (default: true)
  • searchable: boolean - Enable search functionality (default: true)

Outputs

  • valueChange: PhoneInputValue - Emits complete phone data
  • countryChange: CountryModel - Emits when country changes

NgxCountrySelect

Inputs

  • placeholder: string - Placeholder text
  • disabled: boolean - Disable the component
  • defaultCountry: string - Initial country (ISO2 code)
  • preferredCountries: string[] - Countries to show at top
  • showDialCode: boolean - Show dial codes (default: true)
  • showFlag: boolean - Show country flags (default: true)
  • searchable: boolean - Enable search (default: true)

Outputs

  • countryChange: CountryModel - Emits selected country

Reactive Forms

Both components implement ControlValueAccessor for full Angular Forms integration.

Data Types

PhoneInputValue

interface PhoneInputValue {
  countryCode: string; // ISO2 code (e.g., 'US')
  dialCode: string; // Dial code (e.g., '+1')
  phoneNumber: string; // Phone number without dial code
  fullNumber: string; // Complete phone number
  isValid: boolean; // Basic validation result
}

CountryModel

interface CountryModel {
  name: string; // Country name
  iso2: string; // ISO 3166-1 alpha-2 code
  flag: string; // Unicode flag emoji
  dialCode: string; // International dial code
}

Styling

Components use CSS custom properties for easy theming:

ngx-country-select {
  --border-color: #d1d5db;
  --border-radius: 8px;
  --background: white;
  --text-color: #111827;
  --focus-color: #3b82f6;
}

Recent Improvements

Enhanced Phone Input Component

The NgxPhoneInput component has been enhanced with new features:

  1. Search Functionality: Added a search input to the country dropdown that allows users to filter countries by name, dial code, or ISO code.

  2. Configurable Display Options:

    • showFlags: Control whether country flags are displayed (default: true)
    • showDialCode: Control whether dial codes are displayed (default: true)
    • searchable: Control whether the country list is searchable (default: true)
  3. Improved Accessibility:

    • Added proper ARIA attributes for screen readers
    • Enhanced keyboard navigation support (Enter, Space, Escape, Arrow keys)
    • Better focus management and visual indicators
  4. Enhanced UI/UX:

    • Consistent styling with the NgxCountrySelect component
    • Improved responsive design for mobile devices
    • Better visual feedback and hover effects

Example Usage with New Features

// Phone input with flags hidden
<ngx-phone-input
  [showFlags]="false"
  placeholder="Enter phone number" />

// Phone input with dial code hidden
<ngx-phone-input
  [showDialCode]="false"
  placeholder="Enter phone number" />

// Phone input without search functionality
<ngx-phone-input
  [searchable]="false"
  placeholder="Enter phone number" />

Development

# Build the library
ng build ngx-phone-country-input

# Run tests
ng test ngx-phone-country-input

# Run demo
ng serve

License

MIT