Vue Country Flag Component

2.3.2 · active · verified Tue Apr 21

vue-country-flag is a lightweight Vue 2 component designed for displaying country flags, primarily utilizing ISO 3166-1 alpha-2 or alpha-3 country codes. The package is currently stable at version 2.3.2, with its release cadence focusing on bug fixes, adding new flags, and minor feature enhancements such as `rounded` borders and `shadow` effects. A key differentiator and performance improvement was introduced in v2.1.0, which shifted from embedding flag images as base64 strings in CSS to loading them as separate files, significantly reducing the bundle size by approximately 700KB. Although a patch in v2.0.4 noted it was 'usable on Vue3', its `peerDependencies` explicitly target Vue 2 (`^2.6.12`), indicating its core compatibility. It supports customizable sizes ('small', 'normal', 'big') and is marked as TypeScript supported.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to globally register the `CountryFlag` component and use it within a basic Vue 2 application, showcasing different `country`, `size`, `rounded`, and `shadow` prop configurations.

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

// Register the component globally
Vue.component('country-flag', CountryFlag);

// Example Vue app setup
new Vue({
  el: '#app',
  template: `
    <div id="app">
      <h1>Country Flags</h1>
      <p>Displaying various country flags with different sizes and styles.</p>
      <country-flag country='us' size='big' shadow />
      <country-flag country='fr' size='normal' />
      <country-flag country='de' size='small' rounded />
      <country-flag country='jp' />
      <country-flag country='rus' size='big' />
    </div>
  `
});

view raw JSON →