0.0.2 • Published 6 years ago

react-countries-input v0.0.2

Weekly downloads
54
License
MIT
Repository
github
Last release
6 years ago

React Countries Input

A React Component for to select countries calling code with flag inspired on restcountries.eu api and emotion to style.

Getting Started

yarn add react-countries-input
or
npm install react-countries-input --save

Demo

Demo Demo2

How to use

Basic

import React from 'react'
import ReactDOM from 'react-dom'
import ReactCountriesInput from 'react-countries-input'

class MyComponent extends React.Component {
  onChange = value => {
    console.log(response)
  }

  render() {
    return <ReactCountriesInput onChange={this.onChange} />
  }
}

export default MyComponent

Parameters

paramsvaluedefault value
onChangefunctionRequired
containerStyleobjectnone
flagStyleobjectnone
selectWrapperStyleobjectnone
inputStyleobjectnone

Styling example

Since this package is using emotion you can style like you would with emotion

import React from 'react'
import ReactCountriesInput from 'react-countries-input'

class MyComponent extends React.Component {
  onChange = value => {
    console.log(response)
  }

  render() {
    return (
      <ReactCountriesInput
        onChange={this.onChange}
        containerStyle={{
          background: 'red'
        }}
        flagStyle={{
         '&img': {
           width: 30
           height: 15
         }
        }}
        .....
      />
    )
  }
}


export default MyComponent