react-country-icons
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

React Country Icons

A lightweight React component library for displaying country flags. Easily render flags of any country using their ISO 3166-1 alpha-2 country codes.

Installation

Install the package using npm:

npm install react-country-icons

Or using yarn:

yarn add react-country-icons

Usage

Import the Flag component and use it in your React application:

import React from 'react'
import Flag from 'react-country-icons'

const App: React.FC = () => {
    return (
        <div>
            <Flag size={32} country="DE"/> {/* German flag */}
            <Flag size={48} country="US"/> {/* US flag */}
            <Flag size={24} country="FR"/> {/* French flag */}
            <Flag size={32} square country="TR"/> {/* Turkish flag in square form */}
        </div>
    )
}

export default App

Props

Prop Type Description Example
size number Height of the flag in pixels. 32
country string ISO 3166-1 alpha-2 country code. "DE"
square boolean Forms icon into square shape true

Supported Country Codes

The package supports all ISO 3166-1 alpha-2 country codes. Here are some examples:

  • DE - Germany
  • US - United States
  • FR - France
  • GB - United Kingdom
  • JP - Japan

For a full list of country codes, refer to the ISO 3166-1 alpha-2 standard.


License

This project is licensed under the MIT License.

Acknowledgments

  • Flag images sourced from Wikipedia.

  • Built with React and TypeScript.

Author

npm: melihfirat

github: firatmelih

Package Sidebar

Install

npm i react-country-icons

Weekly Downloads

21

Version

1.1.7

License

MIT

Unpacked Size

3.5 MB

Total Files

261

Last publish

Collaborators

  • melihfirat