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.
npm install vue-country-flagVerified import paths — ran on the pinned version, not inferred.
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.
Review your CSS and update selectors to match the new class names. Consult the component's generated HTML for the current class structure.
Ensure your build process and deployment environment are configured to correctly serve static assets. No direct code change is typically needed for standard setups, but be aware of potential issues in highly customized environments.
For production Vue 3 applications, consider using a flag component specifically designed and maintained for Vue 3. Use this package with caution in Vue 3, understanding its primary target is Vue 2.
Always use valid ISO 3166-1 alpha-2 (e.g., 'us', 'fr') or alpha-3 (e.g., 'usa', 'fra') codes. Refer to the 'Available Flags' section in the documentation for a full list of supported codes.
Ensure you have either registered it globally via `Vue.component('country-flag', CountryFlag)` in your `main.js` or locally within the `components` option of your Vue component: `components: { CountryFlag }`.Run `npm install vue-country-flag` or `yarn add vue-country-flag`. Verify your import statement: `import CountryFlag from 'vue-country-flag'`.
Ensure you pass a valid ISO 3166-1 alpha-2 or alpha-3 string to the `country` prop, e.g., `<country-flag country='it' />`.