Menu

SVG version

Use the SVG files for the web and design tools - they scale without quality loss and come in four visual styles.

Installation

npm install @tabler/flags
yarn add @tabler/flags
pnpm install @tabler/flags
bun install @tabler/flags

or just download from GitHub.

Usage

The package has one directory per visual style, and one SVG file per flag inside it. The file name is the flag's slug, for example poland.svg:

node_modules/@tabler/flags/dist/
  rounded/poland.svg
  plain/poland.svg
  gradient/poland.svg
  shiny/poland.svg
  flags.json
  • rounded is the default look, with rounded corners and a thin inset border - the same look as the CSS plugin.
  • plain is the bare flag on a 5:4 canvas, for when you draw your own frame.
  • gradient and shiny add a soft shading on top of the flag.

Load a file as an image and set its size with CSS. Every flag has the same 5:4 ratio, so set the width or the height and the other side follows:

<img src="node_modules/@tabler/flags/dist/rounded/poland.svg" alt="Poland" width="30" height="24" />

A flag can also be a background-image, which is how the CSS plugin works:

.flag-poland {
  background: url('node_modules/@tabler/flags/dist/plain/poland.svg') no-repeat center / cover;
}

List of flags

flags.json lists every flag with its name, category and ISO code, keyed by slug. Use it to build a country select or to map an ISO code to a file:

import flags from '@tabler/flags/flags.json';

flags.poland; // { name: 'Poland', category: 'Countries', iso: 'PL' }

The full list of flags, slugs and ISO codes is in the repository README.