vue-flag-icon is a Vue 2 component designed to display country flags within Vue applications, leveraging the popular `flag-icon-css` library. It provides a simple `<flag>` component that accepts an `iso` prop for the two-letter ISO country code, automatically rendering the corresponding flag. Additional props like `squared` (to toggle between rectangular and square aspect ratios, `true` by default) and `title` (for accessibility and hover text) are supported. The package is currently at version 2.1.0, primarily targeting Vue 2. Due to its dependency on Vue 2's API (`Vue.use()` for global registration), it is generally considered to be in maintenance mode, with no active development for Vue 3 compatibility. It distinguishes itself by offering a straightforward wrapper for `flag-icon-css`, simplifying flag integration for Vue 2 projects without requiring direct CSS manipulation for each flag.
npm install vue-flag-iconVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install and globally register `vue-flag-icon` in a Vue 2 application, then use the `<flag>` component with various props like `iso`, `squared`, and `title`.
For Vue 3 projects, consider using alternative flag icon libraries designed for Vue 3 or directly integrate `flag-icon-css` and wrap it in a custom Vue 3 component.
Ensure you add `import 'flag-icon-css/css/flag-icon.min.css';` to your main JavaScript file (e.g., `main.js`) or a global stylesheet that is part of your build pipeline.
Wrap the `<flag>` component in a `div` or other element and apply `font-size` style, e.g., `<div style="font-size: 180px;"><flag iso="it" /></div>`.
Continue using `Vue.use(FlagIcon)` for Vue 2 projects. If migrating to Vue 3, this package is not compatible and an alternative approach is needed.
Ensure you have `import FlagIcon from 'vue-flag-icon';` and `Vue.use(FlagIcon);` in your main JavaScript entry file (e.g., `main.js`).
Verify that `flag-icon-css` is installed (`npm install flag-icon-css`) and that its CSS is imported, for example, by adding `import 'flag-icon-css/css/flag-icon.min.css';` to your `main.js` or a global style file.
Run `npm install vue-flag-icon --save` (or `yarn add vue-flag-icon`) to install the package, and double-check the import statement for any typos.