react-country-icons
v1.1.7
Published
Vector (*.svg) country flag icons for React.
Maintainers
Readme
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-iconsOr using yarn:
yarn add react-country-iconsUsage
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 AppProps
| 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- GermanyUS- United StatesFR- FranceGB- United KingdomJP- 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
