vue-country-flags
Vue country flags
4,083
| Install | |
|---|---|
npm install vue-country-flags |
|
| Latest Version: | 1.0.2 |
| License: | MIT |
| Last Updated: | Feb 26, 2019 |
| Links: | npm |
Maintainer: muyaedward
Vue-Flag-Icon
a Vue2 Compoment for flag-icon-css
Install
npm i --save vue-country-flags
Usage
Just declare the global Compoment with the use directive in your app
import countryFlag from 'vue-country-flags'
Vue.use(countryFlag);
Then to use it
<template>
<div>
...
<countryflag iso="it" />
<countryflag iso="gb" />
<countryflag iso="us" />
...
</div>
</template
To see a full set of all the icons and countries iso codes visit the flag-icon-css website. There are 246 different icons there.
Being svg files they are resizable as long as you set the font size accordingly in a wrapper element
<div style="font-size:180px">
<countryflag iso="it" />
</div>
The property iso can be as well dinamically set from an object
let guy = {
name: "Vincenzo",
nationality: "it"
}
in the Compoment you should dinamically bind the value
<countryflag :iso="guy.nationality" />
Screenshot
Code Example
(it is the basic vue-cli webpack template)
<template>
<div id="app">
<hello></hello>
<countryflag iso="it" />
<countryflag iso="gb" />
<countryflag iso="us" />
</div>
</template>
<script>
import Hello from './components/Hello'
export default {
name: 'app',
components: {
Hello
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
Additional Props
From 1.0.4 you can now specify two different properties:
- squared : it will render the flag as a square if true, otherwise the flag will be rectangular shaped (true by default).
- title : you can specify the title of the flag icon, (by default it will be overwritten by the iso)
Result

Related Packages
vue-lang-code-flags
Vue component which shows the flag of the country from which the language comes...
38,986
12
@growthbunker/vueflags
One easy-to-use flag component for Vue.js with all ISO 3166-1 countries.
41,021
119
Version History
| Version | Released | License |
|---|---|---|
| 1.0.2 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | ISC |
