jensbodal / country-flag-icons

Vector (*.svg) country flag icons in 3x2 aspect ratio

Home Page:https://catamphetamine.github.io/country-flag-icons/3x2/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

country-flag-icons

npm version npm downloads

Vector country flag icons in 3x2 aspect ratio.

  • Optimized for small size on screen (little detail, minimalism).
  • Small file size.
  • Comes with React components for all flags (exported from /react subpackage).

See the flags (3x2)

Install

npm install country-flag-icons --save

Use

hasFlag(country: string)

Tells whether there's a flag for a country.

import { hasFlag } from 'country-flag-icons'

hasFlag('US') === true
hasFlag('ZZ') === false

Web

Flags can be linked directly from this library's github pages website.

<img
  alt="United States"
  src="http://catamphetamine.github.io/country-flag-icons/3x2/US.svg"/>

Unicode

Unicode flag icons are available under the /unicode export.

import getUnicodeFlagIcon from 'country-flag-icons/unicode'

getUnicodeFlagIcon('US') === '๐Ÿ‡บ๐Ÿ‡ธ'
getUnicodeFlagIcon('ZZ') === '๐Ÿ‡ฟ๐Ÿ‡ฟ'

Unicode flag icons ("Regional Indicator Symbols") were introduced in 2010 in Unicode version 6.0.

Older operating systems might not support Unicode flags, either rendering "missing" (rectangle) characters (if their system doesn't support country flags), or displaying two-letter country codes instead of emoji flag images. For example, Windows 10 currently (01.01.2020) doesn't support Unicode country flags, and displays two-letter country codes instead of emoji flag images.

React

React components for all flags are available at /react/3x2 export.

import Flags from 'country-flag-icons/react/3x2'

<Flags.US title="United States" className="..."/>

Alternatives

  • FlagKit โ€” Simple and beautiful flag icons. 4x3 aspect ratio. MIT licence.

Licence

  • Most flags are from this 262 country flag icons pack. The license quoted there requires "attribution" and doesn't allow "distributing" the icons, so this icon pack including the icons is most likely not legal, even if you have "Premium" subscription on their website, and even if the "attribution" text is included on a page.

  • Some flags (AC, SH, TA, AQ, GS, KI, MP, SZ, NC) were drawn by me in a vector graphics editor.

  • Some flags (GY, OS, TV, WF) were downloaded from Wikipedia (which usually licences stuff under CC BY-SA 3.0 or "Public domain").

About

Vector (*.svg) country flag icons in 3x2 aspect ratio

https://catamphetamine.github.io/country-flag-icons/3x2/


Languages

Language:JavaScript 100.0%