Giter Club home page Giter Club logo

react-simple-phone-input's Introduction

React Simple Phone Input

A simple and customizable react phone number dropdown component. It can mix up with your designed theme and give a fluent vibe able dropdown area in your next project.

npm version npm downloads PRs Welcome MIT licensed

  • SSR Friendly
  • Customizable
  • Multi Design
  • Search Country
  • Smallest Bundle Size (About 98kb)
  • Typescript support

Installation

$ npm i react-simple-phone-input --save

Usage

import { PhoneInput, PhoneInputResponseType } from "react-simple-phone-input";
import "react-simple-phone-input/dist/style.css";

<PhoneInput
    country="US"
    placeholder="Add your phone"
    onChange={(data: PhoneInputResponseType) => console.log(data)}
/>

Options

Name Type Description Is Required Example
country string initial country required "BD"
placeholder string Input Field Placeholder Text required Type your phone number
value string Input field state value or default value optional
iconComponent ReactNode Dropdown Icon component for changing default icon optional <Icon icon="icon-name" />
inputProps InputHTMLAttributes Props to pass into the input field optional
onlyCountries array Show only country in dropdown menu with Country Codes optional ["BD", "US", "AF", "AL"]
excludeCountries array If you want to remove some country to the list. If you give excludeCountries then onlyCountries not works optional ["AF", "AL"]
preferredCountries array Country codes to show on the top of the dropdown menu optional ["BD", "US"]
searchPlaceholder string Search input field placeholder optional
searchIconComponent ReactNode If search enabled, custom search icon to show on search bar optional <Icon icon="icon-name" />
searchProps InputHTMLAttributes Props to pass into the search input field optional
searchNotFound string Error message when search result is empty! optional

Other Options

Name Default Description
showDropdownIcon true Show or Hide dropdown icon
dialCodeInputField false Show calling code into into field or show beside country flag. For more, see example
search true Show or Hide search input field
showSearchIcon true Show or Hide search icon
disableDropdownOnly false Disable dropdown menu list
disableInput false Disable input field

Event

Event Name Description Example
onChange To get the value from component. You get following field
  • country
  • code
  • dialCode
  • value
  • valueWithoutPlus
onChange={(data: PhoneInputResponseType) => console.log(data)}

ClassName

Name Type Description
containerClass string class name for container
buttonClass string class name for dropdown button
dropdownClass string class name for dropdown area/menu
dropdownListClass string class name for dropdown list
dropdownIconClass string class name for dropdown icon
searchContainerClass string class name for search bar container
searchInputClass string class name for search input field
searchIconClass string class name for search icon
inputClass string class name for search icon

Customize styles

Name Description
containerStyle phone Input Container style
buttonStyle style for dropdown button
dropdownStyle style for dropdown menu/area
dropdownListStyle style for dropdown list
dropdownIconStyle style for dropdown icon
searchContainerStyle search container style
searchInputStyle search input field style
searchIconStyle search icon style
inputStyle input field style

note: version 5 released. see the changelogs

Contributing

  • Code style changes not allowed
  • Do not create issues about incorrect or missing country data

Issues or correction

If you face any issues, missing data or wrong data about country, you are welcome to create an issue.

Stay in touch

License

MIT licensed

react-simple-phone-input's People

Contributors

siamahnaf avatar

Watchers

 avatar

Forkers

cv-tq

react-simple-phone-input's Issues

Add options to turn off/on dropdown menu animation!

Hello, I am using react-simple-phone-input in my projects. But I want to off drop-down menu animation. But I am not finding any options or docs to turn off drop-down menu animation. If there is already a option to turn off dropdown menu animation then please tell me please how can I do that. Otherwise please add this options soon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.