Home

Awesome

vue-country-flag

Country flags as a Vue Component

<p align="center"> <img src="https://github.com/P3trur0/vue-country-flag/blob/master/assets/logo.png?raw=true" alt="vue-country-flag"/> </p> <p align="center"> <img src="https://img.shields.io/npm/dm/vue-country-flag" alt="Monthly downloads"> <img src="https://packagephobia.now.sh/badge?p=vue-country-flag@2.3.2" alt="Install size"> <img src="https://img.shields.io/badge/Vue.js%202-compatible-green.svg" alt="Vue.js 2 compatible"> <img src="https://img.shields.io/badge/Vue.js%203-compatible-green.svg" alt="Vue.js 3 compatible"> <a href="https://www.npmjs.com/package/vue-country-flag"><img src="https://img.shields.io/badge/npm-2.3.2-blue.svg" alt="Version"></a> <a href="https://www.npmjs.com/package/vue-country-flag"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a> <img src="https://img.shields.io/badge/TypeScript-supported-blue" alt="TypeScript Supported"> </p>

Vue 3 support

Since version 2.0.3, this component supports both Vue2 and Vue3 support.

In order to use it with Vue 3, please install the vue-country-flag-next package as follows:

npm install vue-country-flag-next

Vue 2 support

How to install

Get the package from NPM:

npm install vue-country-flag

How to use the component

Register CountryFlag component in your app. You can use two approaches:


import Vue from 'vue'
import CountryFlag from 'vue-country-flag'

Vue.component('country-flag', CountryFlag)

import CountryFlag from 'vue-country-flag'

new Vue({
    components: {
        CountryFlag
    }
})

Then, after the proper mounting, in your template you can call it like this:

    <country-flag country='it' size='big'/>
    <country-flag country='hr' size='normal'/>
    <country-flag country='fr' size='small'/>
    <country-flag country='rus'/>

API

Mandatory properties

PropertyDescriptionTypeValue
countryISO 3166-1 identifier of the countryStringone of the values defined here or in the extra flags

Optional properties

PropertyDescriptionTypeValue
sizeFlag sizeStringsmall, normal, big
roundedFlag with rounded bordersBooleanfalse by default
shadowFlag with box shadow aroundBooleanfalse by default
backgroundPath where you can upload possible custom flag imagesStringby default it uses the flags bundled in the component

by default, the flag is displayed at normal size.

Available Flags

The flags are identified using the ISO 3166-1 standard.
This component currently supports both alpha-2 and alpha-3 alternatives.

Country Namealpha-2alpha-3
Afghanistanafafg
Åland Islandsaxala
Albaniaalalb
Algeriadzdza
American Samoaasasm
Andorraadand
Angolaaoago
Anguillaaiaia
Antarcticaaqata
Antigua and Barbudaagatg
Argentinaararg
Armeniaamarm
Arubaawabw
Australiaauaus
Austriaataut
Azerbaijanazaze
Bahamasbsbhs
Bahrainbhbhr
Bangladeshbdbgd
Barbadosbbbrb
Belarusbyblr
Belgiumbebel
Belizebzblz
Beninbjben
Bermudabmbmu
Bhutanbtbtn
Bolivia (Plurinational State of)bobol
Bonaire, Sint Eustatius and Sababqbes
Bosnia and Herzegovinababih
Botswanabwbwa
Bouvet Islandbvbvt
Brazilbrbra
Virgin Islands (British)vgvgb
British Indian Ocean Territoryioiot
Brunei Darussalambnbrn
Bulgariabgbgr
Burkina Fasobfbfa
Burundibibdi
Cambodiakhkhm
Camerooncmcmr
Canadacacan
Cabo Verdecvcpv
Cayman Islandskycym
Central African Republiccfcaf
Chadtdtcd
Chileclchl
Chinacnchn
Hong Konghkhkg
Macaomomac
Christmas Islandcxcxr
Cocos (Keeling) Islandscccck
Colombiacocol
Comoroskmcom
Congocgcog
Congo, Democratic Republic of thecdcod
Cook Islandsckcok
Costa Ricacrcri
Côte d'Ivoireciciv
Croatiahrhrv
Cubacucub
Curaçaocwcuw
Cypruscycyp
Czechiaczcze
Denmarkdkdnk
Djiboutidjdji
Dominicadmdma
Dominican Republicdodom
Ecuadorececu
Egyptegegy
El Salvadorsvslv
Equatorial Guineagqgnq
Eritreaereri
Estoniaeeest
Ethiopiaeteth
Falkland Islands (Malvinas)fkflk
Faroe Islandsfofro
Fijifjfji
Finlandfifin
Francefrfra
French Guianagfguf
French Polynesiapfpyf
French Southern Territoriestfatf
Gabongagab
Gambiagmgmb
Georgiagegeo
Germanydedeu
Ghanaghgha
Gibraltargigib
Greecegrgrc
Greenlandglgrl
Grenadagdgrd
Guadeloupegpglp
Guamgugum
Guatemalagtgtm
Guernseyggggy
Guineagngin
Guinea-Bissaugwgnb
Guyanagyguy
Haitihthti
Heard Island and McDonald Islandshmhmd
Holy Seevavat
Hondurashnhnd
Hungaryhuhun
Icelandisisl
Indiainind
Indonesiaididn
Iran (Islamic Republic of)irirn
Iraqiqirq
Irelandieirl
Isle of Manimimn
Israelilisr
Italyitita
Jamaicajmjam
Japanjpjpn
Jerseyjejey
Jordanjojor
Kazakhstankzkaz
Kenyakeken
Kiribatikikir
Korea (Democratic People's Republic of)kpprk
Korea, Republic ofkrkor
Kuwaitkwkwt
Kyrgyzstankgkgz
Lao People's Democratic Republiclalao
Latvialvlva
Lebanonlblbn
Lesotholslso
Liberialrlbr
Libyalylby
Liechtensteinlilie
Lithuanialtltu
Luxembourglulux
North Macedoniamkmkd
Madagascarmgmdg
Malawimwmwi
Malaysiamymys
Maldivesmvmdv
Malimlmli
Maltamtmlt
Marshall Islandsmhmhl
Martiniquemqmtq
Mauritaniamrmrt
Mauritiusmumus
Mayotteytmyt
Mexicomxmex
Micronesia (Federated States of)fmfsm
Moldova, Republic ofmdmda
Monacomcmco
Mongoliamnmng
Montenegromemne
Montserratmsmsr
Moroccomamar
Mozambiquemzmoz
Myanmarmmmmr
Namibiananam
Naurunrnru
Nepalnpnpl
Netherlandsnlnld
New Caledoniancncl
New Zealandnznzl
Nicaraguaninic
Nigernener
Nigeriangnga
Niuenuniu
Norfolk Islandnfnfk
Northern Mariana Islandsmpmnp
Norwaynonor
Omanomomn
Pakistanpkpak
Palaupwplw
Palestine, State ofpspse
Panamapapan
Papua New Guineapgpng
Paraguaypypry
Perupeper
Philippinesphphl
Pitcairnpnpcn
Polandplpol
Portugalptprt
Puerto Ricoprpri
Qatarqaqat
Réunionrereu
Romaniarorou
Russian Federationrurus
Rwandarwrwa
Saint Barthélemyblblm
Saint Helena, Ascension and Tristan da Cunhashshn
Saint Kitts and Nevisknkna
Saint Lucialclca
Saint Martin (French part)mfmaf
Saint Pierre and Miquelonpmspm
Saint Vincent and the Grenadinesvcvct
Samoawswsm
San Marinosmsmr
Sao Tome and Principeststp
Saudi Arabiasasau
Senegalsnsen
Serbiarssrb
Seychellesscsyc
Sierra Leoneslsle
Singaporesgsgp
Sint Maarten (Dutch part)sxsxm
Slovakiasksvk
Sloveniasisvn
Solomon Islandssbslb
Somaliasosom
South Africazazaf
South Georgia and the South Sandwich Islandsgssgs
South Sudanssssd
Soviet Unionsusun
Spainesesp
Sri Lankalklka
Sudansdsdn
Surinamesrsur
Svalbard and Jan Mayensjsjm
Eswatiniszswz
Swedenseswe
Switzerlandchche
Syrian Arab Republicsysyr
Taiwan, Province of Chinatwtwn
Tajikistantjtjk
Tanzania, United Republic oftztza
Thailandththa
Timor-Lestetltls
Togotgtgo
Tokelautktkl
Tongatoton
Trinidad and Tobagotttto
Tunisiatntun
Turkeytrtur
Turkmenistantmtkm
Turks and Caicos Islandstctca
Tuvalutvtuv
Ugandauguga
Ukraineuaukr
United Arab Emiratesaeare
United Kingdom of Great Britain and Northern Irelandgbgbr
United States of Americaususa
United States Minor Outlying Islandsumumi
Uruguayuyury
Uzbekistanuzuzb
Vanuatuvuvut
Venezuela (Bolivarian Republic of)veven
Viet Namvnvnm
Virgin Islands (U.S.)vivir
Wallis and Futunawfwlf
Western Saharaehesh
Yemenyeyem
Zambiazmzmb
Zimbabwezwzwe

Extra flags

Country NameFlag Code
Cataloniaes-ca
Englandgb-eng
Europeeu
Gallesgb-wls
Kosovoxk
Scotlandgb-sct
United Nationsun

Credits

The flags used for this Vue components are provided by Flag Icons CSS.

Contributing

Please follow the guidelines here.

Building the packages

During development of the project, you might want to build the packages. This project uses Lerna to manage the two packages.

To build either or both packages, you first need to bootstrap Lerna. From the project root, run:

$ npm run bootstrap

After Lerna has been bootstrapped, you can use the build and build:next scripts defined in package.json:

$ npm run build

$ npm run build:next

See package.json for a full overview of the different build targets.