Assets

Country Flag Icons
Ready for Production

Recommended approach for rendering country flag icons using the country-flag-icons package. Provides comprehensive ISO 3166-1 coverage with built-in React components, tree-shakeable imports, and zero maintenance overhead.

Overview

The recommended approach for rendering country flags in Catalyst applications is the country-flag-icons package (MIT license, 3M+ weekly downloads, 0 dependencies).

This replaces the deprecated @pmi/catalyst-flag-icons package, which required the Catalyst team to manually maintain SVG assets and country code mappings.

Why country-flag-icons?

  • Comprehensive coverage of all ISO 3166-1 country codes plus exceptional reservations (EU, XK, etc.)
  • Built-in React components with TypeScript declarations
  • Tree-shakeable individual imports (~1 KB per flag)
  • SVG flags in 3:2 aspect ratio, optimized for small screen sizes
  • Actively maintained by the open-source community
  • Helper utilities (hasFlag, countries) for validation

Installation

npm install country-flag-icons

Examples

Basic Usage

Import flag components by their ISO 3166-1 alpha-2 country code:

Preview
United StatesUnited KingdomJapanBrazilGermany

Individual Imports (Tree-Shaking)

For smaller bundles, import each flag individually. This ensures your bundler only includes the flags you use:

// Named import (relies on tree-shaking)
import { US } from 'country-flag-icons/react/3x2';

// Individual import (guaranteed tree-shaking)
import US from 'country-flag-icons/react/3x2/US';

Custom Sizing

Flags render as inline SVGs. Control their size with standard CSS classes or inline styles:

Preview
FranceItalySpainNetherlands

Validating Country Codes

Use the hasFlag utility to check if a country code is supported before rendering:

Preview
USSupported
GBSupported
ZZNot supported
EUSupported
XKSupported
INVALIDNot supported

Browse all available country flags. Each flag uses its ISO 3166-1 alpha-2 country code:

Preview
AC
AD
AE
AF
AG
AI
AL
AM
AO
AQ
AR
AS
AT
AU
AW
AX
AZ
BA
BB
BD
BE
BF
BG
BH
BI
BJ
BL
BM
BN
BO
BQ
BR
BS
BT
BV
BW
BY
BZ
CA
CC
CD
CF
CG
CH
CI
CK
CL
CM
CN
CO
CR
CU
CV
CW
CX
CY
CZ
DE
DJ
DK
DM
DO
DZ
EC
EE
EG
EH
ER
ES
ET
EU
FI
FJ
FK
FM
FO
FR
GA
GB
GD
GE
GF
GG
GH
GI
GL
GM
GN
GP
GQ
GR
GS
GT
GU
GW
GY
HK
HM
HN
HR
HT
HU
IC
ID
IE
IL
IM
IN
IO
IQ
IR
IS
IT
JE
JM
JO
JP
KE
KG
KH
KI
KM
KN
KP
KR
KW
KY
KZ
LA
LB
LC
LI
LK
LR
LS
LT
LU
LV
LY
MA
MC
MD
ME
MF
MG
MH
MK
ML
MM
MN
MO
MP
MQ
MR
MS
MT
MU
MV
MW
MX
MY
MZ
NA
NC
NE
NF
NG
NI
NL
NO
NP
NR
NU
NZ
OM
PA
PE
PF
PG
PH
PK
PL
PM
PN
PR
PS
PT
PW
PY
QA
RE
RO
RS
RU
RW
SA
SB
SC
SD
SE
SG
SH
SI
SJ
SK
SL
SM
SN
SO
SR
SS
ST
SV
SX
SY
SZ
TA
TC
TD
TF
TG
TH
TJ
TK
TL
TM
TN
TO
TR
TT
TV
TW
TZ
UA
UG
UM
US
UY
UZ
VA
VC
VE
VG
VI
VN
VU
WF
WS
XA
XC
XK
XO
YE
YT
ZA
ZM
ZW

API Reference

React Components

Each flag is available as a React component from country-flag-icons/react/3x2:

Prop

Type

Utility Functions

Prop

Type

Supported Country Codes

The library supports all ISO 3166-1 alpha-2 country codes, plus:

  • Exceptional reservations: EU (European Union), IC (Canary Islands), AC (Ascension Island), TA (Tristan da Cunha)
  • User-assigned codes: XK (Kosovo), XA (Abkhazia), XO (South Ossetia), XC (Northern Cyprus)
  • Subdivision codes: GB-ENG, GB-SCT, GB-WLS, GB-NIR, BQ-BO, BQ-SA, BQ-SE, ES-CT

Accessibility

Flag icons are inline SVGs, so their accessibility depends on how they are used. Decide whether each flag is informative or decorative in context.

Informative Flags

When the flag is the only way a user can identify the country (no visible text label nearby), it is informative and needs an accessible name:

{
  /* Flag is the sole identifier — title required */
}
<US title="United States" className="h-6" />;

Use the full country name ("United States", "United Kingdom") rather than the ISO code ("US", "GB"). Your application should pass a stable, pre-resolved country name through the title prop to avoid server/client rendering mismatches.

Decorative Flags

When the flag appears alongside a visible text label that already identifies the country, the flag is decorative and should be hidden from assistive technologies to avoid redundant announcements:

{
  /* Country name is already visible — flag is decorative */
}
<div className="flex items-center gap-2">
  <US aria-hidden="true" className="h-5" />
  <span>United States</span>
</div>;

Avoid redundant announcements

If a flag has a title and sits next to visible text with the same information, screen reader users will hear the country name twice. Use aria-hidden="true" (and omit title) to prevent this.

Quick Decision Guide

ScenarioFlag roleWhat to do
Flag is the only country indicatorInformativeAdd title with full country name
Flag is next to a visible country nameDecorativeAdd aria-hidden="true", omit title
Flag is inside a labeled control (e.g., phone input)DecorativeAdd aria-hidden="true", omit title
Flag is used in a tooltip or icon-only buttonInformativeAdd title or label the parent button

Migration from @pmi/catalyst-flag-icons

Migration Guide

The deprecated @pmi/catalyst-flag-icons package will continue to work during the transition period. We recommend migrating to country-flag-icons at your earliest convenience.

Key Differences

Feature@pmi/catalyst-flag-iconscountry-flag-icons
Import stylePascalCase names (Usa, UnitedKingdom)ISO alpha-2 codes (US, GB)
Sizingsize prop (xs, sm, md, lg, xl)CSS classes (h-4, h-6, h-8)
Colorscolor prop (original, primary, etc.)Always renders original flag colors
Accessibilitydata-testid proptitle prop for screen readers
Coverage~196 flags250+ flags including territories

Migration Examples

Before (deprecated):

import { Usa, UnitedKingdom, Germany } from '@pmi/catalyst-flag-icons';

<Usa size="lg" color="original" />
<UnitedKingdom size="md" color="original" />
<Germany size="sm" color="original" />

After (recommended):

import { US, GB, DE } from 'country-flag-icons/react/3x2';

<US title="United States" className="h-8" />
<GB title="United Kingdom" className="h-6" />
<DE title="Germany" className="h-5" />

Size Mapping Reference

Old size propPixel sizeEquivalent CSS class
xs16pxh-4
sm20pxh-5
md24pxh-6
lg32pxh-8
xl40pxh-10

On this page