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

Overview

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 --dev flag-icons
# or
yarn add --dev flag-icons

Usage

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 . 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 *.less 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.less 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.
Comments
  • Great Britain Flags

    Great Britain Flags

    • [x] England - gb-eng - svg
    • [x] ~~Northern Ireland - gb-nir~~
    • [x] Scotland - gb-sct
    • [x] Wales - gb-wls - svg
    • [x] Add new source files for new flags

    https://en.wikipedia.org/wiki/ISO_3166-2:GB

    Fixes #112

    opened by lipis 30
  • SVG optimization

    SVG optimization

    Hi! I'm opening an issue, but this is more like an idea. For distribution (bower, etc), I think that the flags could be minimized using tools like SVGO to reduce images, yet maintaining quality. I just made a quick test here and these are the results:

    [ flag-icon-css/flags ] $ du -hx --max-depth=1
    4.6M    ./1x1
    3.6M    ./1x1.min
    4.6M    ./4x3
    3.7M    ./4x3
    

    Rounding numbers, ~2M can be ripped of in production :)

    Hope this helps!

    Best regards, Richard.

    opened by vltr 29
  • Add Galician (Spain) flag

    Add Galician (Spain) flag

    Flag obtained from Wikimedia: https://commons.wikimedia.org/wiki/File:Flag_of_Galicia.svg

    Also added this flag and the catalonian one to the index page.

    BTW, thanks for the library!

    opened by jorgelf 24
  • Large filesize due to complex vector shapes

    Large filesize due to complex vector shapes

    A few of the flags have a pretty large file size due to overly complex vector shapes (especially the the flags of Serbia and the Dominican Republic, both almost 500kb). If look at this close-up of the Serbian flag you notice that there are way to many vector points and it can be dramatically simplified.

    2016-10-19 01 47 28 pm
    opened by generator85 23
  • Wrong flag for United Kingdom (GB)

    Wrong flag for United Kingdom (GB)

    https://en.wikipedia.org/wiki/Flag_of_the_United_Kingdom#/media/File:Flag_of_the_United_Kingdom.svg https://github.com/lipis/flag-icon-css/blob/master/flags/4x3/gb.svg https://github.com/lipis/flag-icon-css/blob/master/flags/1x1/gb.svg

    wrong-flag 
    opened by lipis 19
  • ISO 3166-1 alpha-3

    ISO 3166-1 alpha-3

    Hi, great job! Did you think about add also the ISO 3166-1 alpha-3 code? It should be not so difficult... something like this: before:

    .flag-icon-it {
      background-image: url(../flags/4x3/it.svg);
    }
    

    after

    .flag-icon-it, .flag-icon-ita  {
      background-image: url(../flags/4x3/it.svg);
    }
    

    Thankyou!

    opened by Filoz 16
  • Only 1x1 ration showing...

    Only 1x1 ration showing...

    Hello, I only have the 1x1 flag appearing... Am I doing wrong? I am using angular 9: Capture d’écran 2020-04-19 à 11 22 27 Capture d’écran 2020-04-19 à 11 22 32

    <span *ngFor="let lang of languages" (click)="frame.show()" class="flag-icon flag-icon-{{lang.isocode}}"></span>

    I installed using standard npm install Thanks.

    UPDATE I replaced the pics from the 3x4 folder into the 1x1 folder and now it work.. i have no idea why it charge the wrong folder....

    opened by Spiff77 15
  • Language Flags

    Language Flags

    I have missed the possibility to get a flag by the language. So i added .flag-icon-lang-en

    Here is the new flag-icon-base.scss:

    $countries: (
    dj: "aa", ru: "ady", na: "af", gh: "ak", et: "am", sy: "arc", in: "as", tr: "av", bo: "ay", az: "az", om: "bal", by: "be", zm: "bem", bg: "bg", mu: "bho", vu: "bi", ml: "bm", fr: "br", pk: "brh", ba: "bs", es: "ca", fm: "chk", sg: "cmn", cz: "cs", cs: "cu", is: "da", tg: "dag", de: "de", ne: "dje", cn: "dta", mv: "dv", bt: "dz", al: "el", gb: "en", ee: "et", ae: "fa", gm: "ff", no: "fi", sd: "fia", mp: "fil", fj: "fj", dk: "fo", mr: "fuc", wf: "fud", md: "gag", ki: "gil", ar: "gn", im: "gv", tw: "hak", us: "haw", il: "he", sr: "hns", pg: "ho", at: "hr", ht: "ht", hu: "hu", am: "hy", id: "id", ng: "ig", it: "it", ca: "iu", jp: "ja", ge: "ka", cd: "kg", kz: "kk", gl: "kl", kh: "km", iq: "ku", er: "kun", kg: "ky", va: "la", lu: "lb", ug: "lg", la: "lo", lt: "lt", lv: "lv", sl: "men", eh: "mey", mg: "mg", mh: "mh", ck: "mi", mk: "mk", mn: "mn", mt: "mt", pt: "mwl", mm: "my", nr: "na", zw: "nd", nu: "niu", nl: "nl", za: "nr", mw: "ny", bq: "pap", pw: "pau", pl: "pl", gw: "pov", af: "ps", ch: "rm", bi: "rn", me: "rom", rw: "rw", cf: "sg", si: "sh", lk: "si", as: "sm", se: "sma", fi: "smn", rs: "sr", td: "sre", ls: "st", tl: "tet", tj: "tg", my: "th", tk: "tkl", tv: "tvl", pf: "ty", ua: "uk", vn: "vi", mz: "vmw"
    );
    
    
    @mixin flag-icon-background {
        background-size: contain;
        background-position: 50%;
        background-repeat: no-repeat;
    }
    
    .flag-icon {
        @include flag-icon-background();
        position: relative;
        display: inline-block;
        width: (4 / 3) * 1em;
        line-height: 1em;
        &:before {
            content: '\00a0';
        }
        &.flag-icon-squared {
            width: 1em;
        }
    }
    
    @mixin flag-icon($country) {
        .flag-icon-#{$country} {
            background-image: url(#{$flag-icon-css-path}#{$flag-icon-rect-path}/#{$country}.svg);
            &.flag-icon-squared {
                background-image: url(#{$flag-icon-css-path}#{$flag-icon-square-path}/#{$country}.svg);
            }
        }
        $langCountry: map-get($countries, $country);
        @if $langCountry != '' {
            .flag-icon-lang-#{$langCountry} {
                background-image: url(#{$flag-icon-css-path}#{$flag-icon-rect-path}/#{$country}.svg);
                &.flag-icon-squared {
                    background-image: url(#{$flag-icon-css-path}#{$flag-icon-square-path}/#{$country}.svg);
                }
            }
        }
    }
    
    opened by mxframe 14
  • Share project via Packagist.org

    Share project via Packagist.org

    This would be a great addition to my Symfony project, which makes use of Composer to handle the package dependencies.

    Any option that this project can be required via Packagist.org ?

    opened by rvanlaak 14
  • Failing build some country icons because of unresolved '%23b'

    Failing build some country icons because of unresolved '%23b'

    Despite successfull npm install, some countries such as nu.svg, nz.svg, np.svg are causing npm start failure.

    Here is the error I'm getting:

    ERROR in ./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/flag-icon-css/css/flag-icon.css (Emitted value instead of an instance of Error) CssSyntaxError: F:\repositories\platformui\node_modules\flag-icon-css\css\flag-icon.css:1042:1393: Can't resolve '%23c' in 'F:\repositories\platformui\node_modules\flag-icon-css\css'

    If I comment these flags in node_modules, the server successfully starts.

    Environment: Windows 10 npm --version 5.6.0

    Below is the package.json:

    
    {
      "name": "indigitaUI",
      "version": "1.0.0-snapshot",
      "description": "indigita UO",
      "author": "indigita SA",
      "url": "https://www.indigita.ch",
      "copyright": "",
      "license": "",
      "scripts": {
        "ng": "ng",
        "start": "ng serve --proxy-config proxy.conf.json",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@angular/animations": "5.1.0",
        "@angular/common": "5.1.0",
        "@angular/compiler": "5.1.0",
        "@angular/core": "5.1.0",
        "@angular/forms": "5.1.0",
        "@angular/http": "5.1.0",
        "@angular/platform-browser": "5.1.0",
        "@angular/platform-browser-dynamic": "5.1.0",
        "@angular/router": "5.1.0",
        "@angular/upgrade": "5.1.0",
        "@swimlane/ngx-charts": "^7.0.1",
        "angular2-jwt": "0.2.3",
        "bootstrap": "^4.0.0-beta",
        "chart.js": "2.7.1",
        "core-js": "2.5.1",
        "d3": "^4.12.0",
        "flag-icon-css": "^2.9.0",
        "jquery": "^3.2.1",
        "moment": "2.19.3",
        "ng2-charts": "1.6.0",
        "ngx-bootstrap": "2.0.0-beta.10",
        "popper.js": "^1.12.9",
        "primeng": "^5.0.2",
        "rxjs": "5.5.5",
        "spinkit": "1.2.5",
        "tether": "^1.4.3",
        "ts-helpers": "1.1.2",
        "zone.js": "0.8.18"
      },
      "devDependencies": {
        "@angular/cli": "^1.4.2",
        "@angular/compiler-cli": "5.1.0",
        "@types/jasmine": "2.8.2",
        "@types/node": "8.0.56",
        "codelyzer": "4.0.1",
        "jasmine-core": "2.8.0",
        "jasmine-spec-reporter": "4.2.1",
        "karma": "1.7.1",
        "karma-chrome-launcher": "2.2.0",
        "karma-coverage-istanbul-reporter": "1.3.0",
        "karma-jasmine": "1.1.1",
        "karma-jasmine-html-reporter": "0.2.2",
        "protractor": "5.2.1",
        "ts-node": "3.3.0",
        "tslint": "5.8.0",
        "typescript": "2.4.2"
      }
    }
    
    opened by aligit 12
  • Add additional Unicode/Emoji 1.0 flags

    Add additional Unicode/Emoji 1.0 flags

    • AC and TA use St. Helena (SH) flag
    • CP uses France (FR) flag
    • DG uses British Indian Ocean Territory (IO) flag
    • EA uses Spain (ES) flag
    • IC uses new flag

    Defined by Emoji 1.0 spec, closes #729, closes #537

    opened by NotTsunami 11
  • Wrong Flag ac Ascension Island

    Wrong Flag ac Ascension Island

    Thats's the wrong flag, (ac Ascension Island) the correct one is: https://en.wikipedia.org/wiki/Ascension_Island#/media/File:Flag_of_Ascension_Island.svg

    wrong-flag 
    opened by MeEuro 0
  • some space above and below the flag icon

    some space above and below the flag icon

    Hi,

    I'm having issue with putting a border around the flag icon. Their is some space above and below the flag icon if i put some border around the icon.

    For example in this screen shot you can see the white space on above and below the icon screenshot-localhost_4200-2022 10 24-09_33_48

    The reason to put border is to distinguish the flag and background, like in this case: screenshot-localhost_4200-2022 10 24-09_34_35

    Thanks

    bug 
    opened by babatech 2
  • Non unique ids cause rendering collisions when svgs are inlined

    Non unique ids cause rendering collisions when svgs are inlined

    Some flags are corrupted when SVG icons are inlined into the page HTML.

    Codepen: https://codepen.io/vovayatsyuk/pen/eYrPXgW?editors=1000

    1. At the initial page load, the Honduras flag is corrupted.
    2. When changing sort order by clicking on the table header Cameroon and Indian flags get corrupted.

    Screenshot:

    Screenshot

    Possible solution

    Use unique ids to prevent collisions. I've already done that in my laravel package

    If you are interested in this change I'll open PR with updated icons.

    bug 
    opened by vovayatsyuk 4
  • Letter rendered over flag

    Letter rendered over flag

    Sometimes a sort of A character gets rendered over top the flag. I figured this is due to the :before content (which is 00a0) being interpreted as ISO-8859-1 instead of UTF-8 which results in a sort of A character instead of nbsp. I have found this stackoverflow issue about it. I can confirm that the CSS output from webpack does have 0xC2 in front of 0xA0 which, again, sometimes gets rendered as that A character.

    Have you seen this before? I tried setting the @charset in my base SCSS file but that didn't seem to solve it.

    bug help needed 
    opened by larsk2009 7
Releases(v6.6.5)
Owner
Lipis
Currently @Excalidraw, @Prettier. Previously at @wireapp, @EyeTribe, Developer Expert @google.
Lipis
Awesome critique of crypto / web3. Curated list of high quality critique plus background. Seek to be as constructive as possible.

Awesome critique of crypto/web3 Awesome critique of crypto/web3, etc. Contributions are welcome. Critique General Stephen Diehl series - https://www.s

Rufus Pollock 1.5k Jan 1, 2023
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Cli pride flags!

cli-pride-flags Displays pride flags in your terminal~ Click me for a preview! Install npm i -g cli-pride-flags There's also a package in the AUR, mai

Ging Pepper 54 Dec 23, 2022
A curated collection of common interview questions to help you prepare for your next interview.

30 Seconds of Interviews A curated collection of common interview questions to help you prepare for your next interview. This README is built using ma

30 seconds 11k Jan 7, 2023
Manually curated collection of resources for frontend web developers.

Frontend Development Manually curated collection of resources for frontend web developers. You are viewing a browseable version, split by category in

Tim Navrotskyy 36.4k Jan 1, 2023
Manually curated collection of resources, plugins, utilities, and other assortments for the Sapphire Community projects.

Awesome Sapphire Manually curated collection of resources, plugins, utilities, and other assortments for the Sapphire Community projects. Has your pro

Sapphire 20 Dec 17, 2022
A curated collection of resources for learning to build Progressive Web Apps 💪

PWA Resources A curated collection of resources for learning to build Progressive Web Apps ?? Curated and maintained with ♥ by the folks at Shareup. W

Shareup 30 Aug 31, 2022
A curated collection of free resources from across the web for front-end developers, covering everything from design to deployment.

A curated collection of free resources from across the web for front-end developers, covering everything from design to deployment.

Robert McAbee 6 Jul 11, 2022
A Javascript library to export svg charts from the DOM and download them as an SVG file, PDF, or raster image (JPEG, PNG) format. Can be done all in client-side.

svg-exportJS An easy-to-use client-side Javascript library to export SVG graphics from web pages and download them as an SVG file, PDF, or raster imag

null 23 Oct 5, 2022
💻 Countries Web is a web application that lets you view data for all the countries in the world and filter them by country name and continent.

?? Countries Web View Demo This is the Countries Web, a web application that lets you view data for all the countries in the world and filter them by

João Gabriel 5 Jun 23, 2022
Connect Web Integration illustrates the integration of Connect-Web in various JS frameworks and tooling

Connect Web Integration Connect Web Integration is a repository of example projects using Connect-Web with various JS frameworks and tooling. It provi

Buf 43 Dec 29, 2022
An easy-to-use JavaScript library aimed at making it easier to draw on SVG elements.

svg-pen-sketch An easy-to-use JavaScript library aimed at making it easier to draw on SVG elements when using a digital pen (such as the Surface Pen).

Kevin Desousa 8 Jul 27, 2022
TypeScript + Nextjs + Tailwind => TNT🧨 (plus Prettier and ESLint configuration).

Bye bye next boilerplate, welcome to TNT! About This is TNT, Nextjs boilerplate powered by Typescript, Tailwind. This template also has customized ESL

Arvîn mostafaei 15 Aug 7, 2022
🍎Transform an SVG icon into multiple themes, and generate React icons,Vue icons,svg icons

IconPark English | 简体中文 Introduction IconPark gives access to more than 2000 high-quality icons, and introduces an interface for customizing your icon

Bytedance Inc. 6.8k Jan 5, 2023
A collection of functions and methods to make it easier for you to create applications.

def-helper A collection of functions and methods to make it easier for you to create applications. Install npm install --save def-helper Usage import

Dede Fuji Abdul 2 Oct 13, 2022
Break the barrier of your country, language and distance...

HACK ON 2.0 PROJECT METAFRATIS Break the barrier of your country, language and distance... PROBLEM OUR PROJECT SOLVES With the onset of Covid-19 we ha

Snehasish Dhar 16 Jul 6, 2021
An ongoing curated list of frameworks, books, articles, talks, screencasts, recordings, libraries, learning tutorials and shiny resources about Javascript Development.

Javascript Frameworks Development Welcome to the world of Javascript Frameworks. An ongoing curated list of frameworks, books, articles, talks, screen

Paul Veillard 3 Jul 31, 2022