Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

flag-icons

lipis978.2kMIT7.3.2

A curated collection of all country flags in SVG — plus the CSS for easier integration. See the demo.

readme

flag-icons

A curated collection of all country flags in SVG — plus the CSS for easier integration. See the demo.

Install

You can either download the whole project as is or install it via npm or Yarn:

npm install flag-icons
# or
yarn add flag-icons

Usage

First, you need to import css:

import "/node_modules/flag-icons/css/flag-icons.min.css";

or use CDN:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/gh/lipis/flag-icons@7.2.3/css/flag-icons.min.css"
/>

For using the flags inline with text add the classes .fi and .fi-xx (where xx is the ISO 3166-1-alpha-2 code of a country) to an empty <span>. If you want to have a squared version flag then add the class fis as well. Example:

<span class="fi fi-gr"></span> <span class="fi fi-gr fis"></span>

You could also apply this to any element, but in that case you'll have to use the fib instead of fi and you're set. This will add the correct background with the following CSS properties:

background-size: contain;
background-position: 50%;
background-repeat: no-repeat;

Which means that the flag is just going to appear in the middle of an element, so you will have to set manually the correct size of 4 by 3 ratio or if it's squared add also the flag-icon-squared class.

Development

Run the yarn to install the dependencies after cloning the project and you'll be able to:

To build *.scss files

$ yarn build

To serve it on localhost:8000

$ yarn start

To have only specific countries in the css file, remove the ones that you don't need from the _flag-icons-list.scss file and build it again.

Credits

  • This project wouldn't exist without the awesome and now deleted collection of SVG flags by koppi.
  • Thank you Andrejs Abrickis for providing the flag-icons name on npm.

changelog

7.3.2

  • Add new flag for Association of Southeast Asian Nations (#1325)

7.3.1

  • Fix Kyrgyzstan Flag (#1323)

7.3.0

  • Run the latest svgo on all files (#1322)

7.2.4

  • Fix Syrian Flag (#1310)

7.2.3

  • Fix overlapping paths in at, bg, ee, lu, nl, ru flags (#1251)

7.2.2

  • Fix Malta Flag (#1248)

7.2.1

  • Fix Belarus Flag (#1230)

7.2.0

  • Update all flags with SVGO 3.2.0 (#1224)
  • Update German colors (#1208, #1209)

7.1.0

  • SVGO all files and update fill="#000" to fill="#000001" (#1193)
  • Fix German Flag (#1189, #1190)

7.0.3

  • Fix black SVG elements (#1187)

7.0.2

  • Fix Jersey flag (#1180)

7.0.1

  • Remove <use> tags without href (#1179)

7.0.0

  • Remove Less support (#1174)

6.15.0

  • Run the latest SVGO to all files (#1176)

6.14.0

  • Build with SASS instead of Less the generated CSS (#1172)

6.13.2

  • Fix paths for sh-ta
  • Action for pubishing to npm

6.13.0

  • Saint Helena, Ascension and Tristan da Cunha updates (#1169)

6.12.0

  • Add flag for Pacific Community (#1165)

6.11.2

  • Fix French flags color to use the official ones (#1163)

6.11.1

  • Fix Portuguese flag (#1154)

6.11.0

  • Run SVGO on all files (#1149)

6.10.1

  • Flag of Turkmenistan (#1148)

6.10.0

  • Update Martinique (#1145)
  • Update Saint Helena, Ascension and Tristan da Cunha (#1146)
  • Fix flag of Ascension Island (#1147)
  • Unrelated to flags: Improved homepage

6.9.5

  • Improve Anguilla color and file size (#1138)
  • Update Peru flag (#1137)
  • Update um to match us flag (#1136)

6.9.4

  • Fix Flag of Chad (#1135)

6.9.3

  • Change Turkey to Türkiye (#1125)
  • Move xx back to the top of the CSS (#1129)

6.9.2

  • Update SASS (#1122)
  • Fix remove references to "ea" (#1121)

6.9.1

  • Remove Ceuta and Melilla (#1119)

6.9.0

  • Add East African Community (#1118)
  • Fix Holy See (#1117)

6.8.0

  • Added composer configuration. (#1091)
  • Add Arab League flag (#1116)
  • SVGO ids (#1115)

6.7.0

  • Fix blurry US flag in Safari (#1096)
  • Correcting Tunisia flag to match post 1999 shape updates (#1090)
  • Correct green color in Saudi Arabia flag (#1080)
  • Remove mix-blend-mode from Georgia flag (#1079)
  • Fix flag of Malaysia (#1058)
  • Fix Antigua and Barbuda flags (#1066)
  • Add cefta flag to stylesheets (#1065)
  • Fix flag of Kazakhstan (#1056)
  • Fix flag of Dominican Republic (#1052)
  • Add flag for Basque Country (#1050)
  • Fix colors of Cuban flag (#1044)
  • Fix Nepali flag should be transparent (#1034)
  • Added CDN (#1032)

6.6.6

  • Fix encoding and sort by name the country.json file

6.6.5

  • Fix Albania flag colors (Issue #1028)
  • Fix South Africa flag colors (Issue #1020)

6.6.4

  • Updated country names in country.json
  • Fix Greece
  • Fix Indonesia
  • Fix Japana

6.6.3

  • Updated some of capitals in country.json

6.6.2

  • Remove IDs and add manually the id of the flag to the root

6.6.0

  • Fix Syria
  • Update SVGO settings

6.5.1

  • Fix Eswatini
  • Fix Vanuatu

6.5.0

  • Fix Guatemala
  • Fix Seychelles
  • Fix Myanmar
  • Run SVGO for all flags

6.4.6

  • Fix Mongolia
  • Fix Switzerland
  • Fix Israel
  • Fix China
  • Fix Vietnam

6.4.5

  • Fix colors of Estonia

6.4.4

  • Fix colors of Armenia
  • Fix the union jack of Niue

6.4.3

  • Fix Argentina

6.4.2

  • Convert text to path in flags: sm, gu

6.4.1

  • Added Central European Free Trade Agreement (CEFTA) flag

5.0.0

  • The package name changed from flag-icon-css to flag-icons
  • The class names changed from flag-icon flag-icon-[xx] to fi fi-[xx]