Socket
Book a DemoInstallSign in
Socket

currency-code-to-country-flag

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency-code-to-country-flag

React component to display country flags based on currency codes or country codes

latest
Source
npmnpm
Version
1.0.9
Version published
Weekly downloads
59
-41%
Maintainers
0
Weekly downloads
 
Created
Source

Currency Code to Country Flag

A React component library for displaying country flags based on currency codes or country codes. The package includes local SVG flag files in both square (1:1) and rectangular (4:3) aspect ratios.

Currency Code to Country Flag Demo

Installation

npm install currency-code-to-country-flag
# or
yarn add currency-code-to-country-flag

Usage

You can use the CountryFlag component in two ways:

1. Display flag using currency code

import { CountryFlag } from "currency-code-to-country-flag";

function App() {
  return (
    <div>
      <CountryFlag currency="USD" />
      <CountryFlag currency="EUR" />
      <CountryFlag currency="JPY" />
      <CountryFlag currency="LAK" />
      <CountryFlag currency="THB" />
      <CountryFlag currency="CNY" />
    </div>
  );
}

2. Display flag using country code

import { CountryFlag } from "currency-code-to-country-flag";

function App() {
  return (
    <div>
      <CountryFlag country="US" />
      <CountryFlag country="MM" />
      <CountryFlag country="DE" />
    </div>
  );
}

3. Choose aspect ratio (square or rectangular flags)

import { CountryFlag } from "currency-code-to-country-flag";

function App() {
  return (
    <div>
      <CountryFlag country="US" ratio="square" /> {/* Square flag (1:1) */}
      <CountryFlag country="US" ratio="rectangle" /> {/* Rectangular flag (4:3) */}
    </div>
  );
}

Props

PropTypeDescriptionDefault
currencystringISO 4217 currency code (e.g., 'USD', 'EUR', 'JPY')-
countrystringISO 3166-1 alpha-2 country code (e.g., 'US', 'DE')-
size'16' | '24' | '32' | '48' | '64'Size of the flag image in pixels'32'
ratio'square' | 'rectangle'Aspect ratio of the flag (square 1:1 or rectangular 4:3)'square'
altstringCustom alt text for the flag imageAuto-generated
classNamestringAdditional CSS class names''
styleReact.CSSPropertiesAdditional inline styles{}

Notes

  • Either currency or country prop must be provided.
  • If both are provided, country takes precedence.
  • Currency codes are mapped to their primary issuing country.
  • All currency and country codes should be provided in ISO standard format.
  • The package includes SVG flag files for all countries in both square and rectangular aspect ratios.

Credits

Flag icons provided by flag-icons project.

License

MIT

Keywords

react

FAQs

Package last updated on 18 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts