# antd-country-phone-input

> Country phone input component as standard Ant.Design form item

Latest version **4.5.1** (published 2023-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install antd-country-phone-input
pnpm add antd-country-phone-input
yarn add antd-country-phone-input
bun add antd-country-phone-input
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.5.1 |
| Published | 2023-02-21 |
| First published | 2019-11-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 214.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | wangsijie |
| Maintainers | wangsijie, helsonxiao |
| Keywords | react, antd, ant-design, country, country-code, phone, phone-number, input, cpi, antd-cpi |

## Links

- npm: https://www.npmjs.com/package/antd-country-phone-input
- Repository: https://github.com/boyuai/antd-country-phone-input
- Homepage: https://boyuai.github.io/antd-country-phone-input/
- Issues: https://github.com/boyuai/antd-country-phone-input/issues
- npm.io page: https://npm.io/package/antd-country-phone-input

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 4.5.1 (latest) — 2023-02-21
- 4.5.0 — 2022-11-10
- 4.4.0 — 2022-07-23
- 4.3.3 — 2022-06-09
- 4.3.1 — 2022-02-12
- 4.3.0 — 2022-01-13
- 4.2.1 — 2021-12-01
- 4.2.0 — 2021-11-24
- 4.2.0-rc.0 — 2021-10-29
- 4.1.1 — 2021-09-03
- 4.1.0 — 2021-04-26
- 4.0.0 — 2021-04-23
- 3.4.5 — 2021-04-17
- 3.4.4 — 2021-04-16
- 3.4.3 — 2021-03-22
- … 18 more at https://npm.io/package/antd-country-phone-input/versions

## README

# antd-country-phone-input

Country phone input component as standard Ant.Design form item.

[![dumi][dumi-image]][dumi-url] [![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] [![build status][github-actions-image]][github-actions-url]

[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
[dumi-url]: https://github.com/umijs/dumi
[npm-image]: https://img.shields.io/npm/v/antd-country-phone-input.svg?style=flat-square
[npm-url]: https://npmjs.org/package/antd-country-phone-input
[download-image]: https://img.shields.io/npm/dm/antd-country-phone-input.svg?style=flat-square
[download-url]: https://npmjs.org/package/antd-country-phone-input
[github-actions-image]: https://github.com/boyuai/antd-country-phone-input/workflows/CI/badge.svg
[github-actions-url]: https://github.com/boyuai/antd-country-phone-input/actions

![Preview](https://staticcdn.boyuai.com/user-assets/6074/DvBU2V96oXmxMQ45rrnKUb/2021416-171631.png!png)

## Installation

```bash
npm install antd-country-phone-input world_countries_lists
```
or
```bash
yarn add antd-country-phone-input world_countries_lists
```

## Usage

> **Breaking Changes:**
> 1. To avoid unnecessary encapsulation for different locales, `4.0` lifted areas state up to `ConfigProvider`(based on React Context). You need to put it in the right place(index.js/App.js/...), then all components will have access to the provided config.
> 2. `Tree Shaking` is supported in `4.1`, you need to install `world_countries_lists` explicitly. Thus, you could customize translation JSON and it is better than `areaMapper` in `ConfigProvider`.
> 3. `world_countries_lists` updated their file structure from [2.4.0](https://github.com/stefangabos/world_countries/releases/tag/2.4.0): `world_countries_lists/data/en/world.json` -> `world_countries_lists/data/countries/en/world.json`.

```tsx | pure
import CountryPhoneInput, { ConfigProvider } from 'antd-country-phone-input';
import en from 'world_countries_lists/data/countries/en/world.json';

// Usually you only need to import ConfigProvider & CSS once in App.js/App.tsx
// CSS order is important!
import 'antd/dist/antd.css';
import 'antd-country-phone-input/dist/index.css';

const App = () => {
  return (
    <ConfigProvider locale={en}>
      <CountryPhoneInput />
    </ConfigProvider>
  );
};

export default App;
```

Try it on our website: https://boyuai.github.io/antd-country-phone-input/demos/

### Value

| Field | Type | Note |
| --- | ---- | --- |
| short | string | See [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
| phoneCode | number |
| emoji | ReactNode | National flag
| name | string |

### Locale

See [`world_countries_lists`](https://github.com/stefangabos/world_countries)

### Example

Have a look at [this](https://github.com/boyuai/antd-country-phone-input/tree/master/example)!

---
_Source: https://npm.io/package/antd-country-phone-input · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
