supermario / elm-countries / Countries

A searchable ISO 3166-1 based list of country names, codes and emoji flags.

The library is intended to be used qualified (i.e. Countries.search, Countries.all).

> import Countries
> Countries.fromCode "AU"
Just { name = "Australia", code = "AU", flag = "🇦🇺" }
    : Maybe.Maybe Countries.Country

See the examples folder for a basic country picker example.

Note: Country names do change! It's best to use the code as a key if you are using and storing country details outside of this library.

Types


type alias Country =
{ name : String
, code : String
, flag : String 
}

The Country record type.

This type is intentionally not opaque, as accessing the countries reference data as easily as possible is the primary goal.

Common helpers

fromCode : String -> Maybe Country

Find a country by its ISO 3166-1 alpha-2 two-letter country code.

fromCodeCustom : List Country -> String -> Maybe Country

Find a country by its ISO 3166-1 alpha-2 two-letter country code, using a custom Countries list

search : String -> List Country

Search all Countries by case-insensitive string matching on name and code

searchCustom : List Country -> String -> List Country

Search a custom Countries list by case-insensitive string matching on name and code

Data set

all : List Country

The full list of all 249 current ISO 3166-1 Country records.