react-js-country-flags

0.1.7 • Public • Published

react-country-flag

Install

npm install --save react-js-country-flags

Result

Result.png

Usage

Pass the country code or dial_code to get details/flag/flag emoji

import React from "react"
import {getFlagsByDialCode,getFlagByCountryName,getFlagEmojiByCountryName,getCountryDetailsByName} from "react-js-country-flags";

function App() {

  const countryList1 = getFlagsByDialCode("+1")
  const countryList91 = getFlagsByDialCode("+91")
  return (
    <div className="App" style={{padding:"10px"}}>
      <p>Country flag by dial code +1 : {JSON.stringify(countryList1)}</p>
      {countryList1.map((country)=> <img key={country.dial_code} src={country.flag} style={{height:'30px',width:'30px',marginRight:'10px'}}/>)}
      <br/>

      <p>Country flag by dial code +91 : {JSON.stringify(countryList91)}</p>
      {countryList91.map((country)=> <img key={country.dial_code} src={country.flag} style={{height:'30px',width:'30px',marginRight:'10px'}}/>)}
      <br/>

      <p>Country flag by name US</p>
       <img src={getFlagByCountryName("US")} style={{height:'30px',width:'30px'}}/>
      <br/>
 
      <p>country Emoji {getFlagEmojiByCountryName("in")}</p>


      <p>Country details by name IN : {JSON.stringify(getCountryDetailsByName("in"))}</p>
     
      <br/>

    </div>
  );
}

export default App;

Detecting Emoji support

Try this out and conditionally render your country flag https://github.com/danalloway/detect-emoji-support

License

MIT © UdaySubbisetty

Package Sidebar

Install

npm i react-js-country-flags

Weekly Downloads

8

Version

0.1.7

License

none

Unpacked Size

2.49 MB

Total Files

271

Last publish

Collaborators

  • uday_subbisetty