Convert Figma logo to code with AI

madebybowtie logoFlagKit

Beautiful flag icons for usage in apps and on the web.

3,028
320
3,028
31

Top Related Projects

:flags: A curated collection of all country flags in SVG — plus the CSS for easier integration

SVG and PNG renders of all countries' flags.

Quick Overview

FlagKit is a collection of flag images for 250+ countries and territories, available in multiple formats including PNG, SVG, and Apple's PDF-based asset format. It provides an easy way for developers to integrate high-quality flag icons into their applications, particularly useful for iOS and macOS projects.

Pros

  • High-quality flag images in multiple formats (PNG, SVG, PDF)
  • Comprehensive collection covering 250+ countries and territories
  • Easily integrable into iOS and macOS projects
  • Regularly updated to reflect changes in national flags

Cons

  • Limited to flag images only, no additional country-related data
  • May require manual updates to stay current with flag changes
  • No built-in localization support for flag names
  • Relatively large file size when including all flags

Code Examples

Since FlagKit is primarily an image asset library, there are no direct code examples. However, here's how you might use it in an iOS project:

// Assuming you've added FlagKit to your project
import FlagKit

// Get a flag image for a country
let flagImage = Flag(countryCode: "US")?.image(style: .roundedRect)

// Set the flag image to a UIImageView
myImageView.image = flagImage

Getting Started

  1. Add FlagKit to your project:

    • For CocoaPods: Add pod 'FlagKit' to your Podfile
    • For Carthage: Add github "madebybowtie/FlagKit" to your Cartfile
    • For Swift Package Manager: Add https://github.com/madebybowtie/FlagKit.git as a package dependency
  2. Import FlagKit in your Swift file:

    import FlagKit
    
  3. Use the Flag class to get flag images:

    let flagImage = Flag(countryCode: "FR")?.image
    

Competitor Comparisons

:flags: A curated collection of all country flags in SVG — plus the CSS for easier integration

Pros of flag-icons

  • Larger collection of flags (260+ countries, territories, and organizations)
  • Multiple formats available (SVG, PNG, CSS sprites)
  • Includes both square and rectangular versions of flags

Cons of flag-icons

  • Larger file size due to the extensive collection
  • Less focused on mobile-specific optimizations
  • May require more setup for integration in certain projects

Code Comparison

FlagKit usage (Swift):

let flag = FlagKit.flag(for: "US")
imageView.image = flag

flag-icons usage (HTML/CSS):

<span class="flag-icon flag-icon-us"></span>

Additional Notes

FlagKit is primarily designed for iOS and macOS applications, offering a streamlined integration for Apple platforms. It provides high-quality, optimized flag images for mobile use.

flag-icons, on the other hand, is more versatile and can be easily used in web projects across various platforms. It offers a wider range of flags and formats, making it suitable for diverse applications.

Both projects are actively maintained and have good documentation. The choice between them largely depends on the specific project requirements, target platform, and desired customization options.

SVG and PNG renders of all countries' flags.

Pros of country-flags

  • Larger collection of flags (over 250 countries and territories)
  • Multiple file formats available (SVG, PNG, WEBP)
  • Includes historical and alternative flags for some countries

Cons of country-flags

  • Less consistent design style across flags
  • Limited documentation and usage instructions
  • No built-in support for iOS or Android integration

Code comparison

FlagKit usage in Swift:

let flag = FlagKit.flag(for: "US")
imageView.image = flag

country-flags usage (generic example):

<img src="path/to/country-flags/svg/us.svg" alt="US Flag">

Summary

country-flags offers a more extensive collection of flags in various formats, including historical and alternative versions. However, FlagKit provides a more consistent design style and better integration for iOS and Android projects. FlagKit also offers more straightforward usage in code, especially for mobile development. country-flags is more suitable for web projects or situations requiring a wider range of flag options, while FlagKit is better suited for mobile app development with a focus on modern country flags.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Header

FlagKit

Beautiful flag icons for usage in apps and on the web. All flags are provided as stand-alone PNG and SVG files. FlagKit also provides an Asset Catalog and framework for easy use on Apple platforms.

Installation (iOS, macOS, tvOS)

FlagKit provides a framework for easy installation as a dependency. You can also manually copy the Asset Catalog into your project.

SwiftPM

Add the folowinig as repository URL:

https://github.com/madebybowtie/FlagKit.git

Carthage

Add the following line to your Cartfile:

github "madebybowtie/FlagKit"

CocoaPods

Add the following line to your Podfile:

pod 'FlagKit'

Manual

Add Assets/FlagKit.xcassets to your target.

Usage (iOS, macOS, tvOS)

FlagKit provides both rectangular unstyled flags and styled flags in a variety of shapes. Our sample project demonstrates how to display flags and customize them into different shapes (rounded corners, square, circle).

Note: Styling is currently not supported by FlagKit on macOS

This brief example loads the flag for the users current locale, and retrieves the unstyled flag and a styled flag:

let countryCode = Locale.current.regionCode!
let flag = Flag(countryCode: countryCode)!

// Retrieve the unstyled image for customized use
let originalImage = flag.originalImage

// Or retrieve a styled flag
let styledImage = flag.image(style: .circle)

You can always access the underlying assets directly, through the bundled Asset Catalog:

let countryCode = Locale.current.regionCode!
let bundle = FlagKit.assetBundle
let originalImage = UIImage(named: countryCode, in: bundle, compatibleWith: nil)

Reference

FlagKit provides over 250 flags. A list of all flags can be found here.

More Info

Have a question? Please open an issue!

License

FlagKit is released under the MIT license. See LICENSE.