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

@aramir/antd-phone-input

v1.0.1

Published

A lightweight phone number input for [Ant Design](https://ant.design/) that shows numbers in national format while storing and emitting the international [E.164](https://en.wikipedia.org/wiki/E.164) standard (`+12133734253`).

Readme

AntD Phone Input

A lightweight phone number input for Ant Design that shows numbers in national format while storing and emitting the international E.164 standard (+12133734253).

Features

  • Uses libphonenumber-js -- reliable formatting and validation used in production across thousands of apps
  • National-format display -- users see (213) 373-4253 instead of +12133734253, which feels natural; the E.164 value is handled internally
  • Ant Design Form integration -- works as a controlled form field out of the box; includes buildPhoneRule() for one-line validation
  • Country search -- searchable dropdown filtered by country name, ISO code, or dial code
  • Controlled & uncontrolled -- supports both value/onChange and defaultValue
  • Full keyboard navigation

View Demo Site

Installation

npm install antd-phone-input

Usage

import { PhoneInput } from "antd-phone-input";

function App() {
  return (
    <PhoneInput
      onChange={(e164) => console.log(e164)} // "+12133734253"
    />
  );
}

Controlled

import { useState } from "react";
import { PhoneInput } from "antd-phone-input";

function App() {
  const [phone, setPhone] = useState<string | undefined>();

  return (
    <PhoneInput
      value={phone}
      onChange={setPhone}
      defaultCountry="GB"
    />
  );
}

Ant Design Form

Use buildPhoneRule() to wire up validation. The component emits undefined when the field is empty, so pair it with a required rule if the field is mandatory.

import { Button, Form } from "antd";
import { PhoneInput, buildPhoneRule } from "antd-phone-input";

function ContactForm() {
  const [form] = Form.useForm();

  return (
    <Form form={form} onFinish={(values) => console.log(values)}>
      <Form.Item
        name="phone"
        label="Phone"
        rules={[
          { required: true, message: "Phone is required" },
          buildPhoneRule(),
        ]}
      >
        <PhoneInput />
      </Form.Item>
      <Button htmlType="submit">Submit</Button>
    </Form>
  );
}

Restricting available countries

<PhoneInput
  allowedCountries={["US", "CA", "GB", "AU"]}
  defaultCountry="US"
/>

Pinning priority countries to the top

<PhoneInput
  priorityCountries={["KY", "GB", "US"]}
  onChange={(e164) => console.log(e164)}
/>

Props Reference

| Prop | Type | Default | Description | |---|---|---|---| | value | string | -- | Controlled E.164 value, e.g. "+12133734253" | | defaultValue | string | -- | Initial E.164 value for uncontrolled usage | | onChange | (value: string \| undefined) => void | -- | Called with an E.164 string on change, or undefined when empty | | defaultCountry | CountryCode | "US" | Country pre-selected when the field has no value | | allowedCountries | CountryCode[] | -- | Restrict the dropdown to this subset of countries | | priorityCountries | CountryCode[] | -- | Countries pinned to the top of the dropdown list | | searchable | boolean | true | Show a search box inside the country dropdown | | callingCode | boolean | true | Show the dial code (e.g. +1) as a label between the flag and the input | | disabled | boolean | false | Disables both the country selector and the phone input |

All other props from Ant Design's Input component are forwarded to the underlying input element (e.g. size, status, style, placeholder).

buildPhoneRule(message?)

Returns an Ant Design Rule that validates a phone number using libphonenumber-js. Empty values always pass -- add a required rule separately if needed.

import { buildPhoneRule } from "antd-phone-input";

const rules = [
  { required: true, message: "Phone is required" },
  buildPhoneRule("Not a valid phone number"),
];