Git Product home page Git Product logo

country-flag-icons's Introduction

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 (flagpack npm package) โ€” 4x3 and 1x1 SVG flag icons. MIT licence.

Credits

I used Google image search for flag references, and various country flag packs (including FlagKit / flagpack) for design ideas. Sometimes there was no need to re-draw a flag โ€” usually in cases when a flag is just a set of colored stripes and there already is a 3x2 SVG version of it somewhere at Wikipedia or some other free flag pack, so in those cases I simply copied those flags (because they look the same in every flag pack).

Some countries officially use their "mother" country flag (those used to be colonies). For example, BV (Bouvet Island) and SJ (Svalbard and Jan Mayen) use the flag of Norway; GP (Guadeloupe) and RE (Rรฉunion) use the flag of France.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.