Skip to content

A beautiful, fully customizable Country Picker for Android with Jetpack Compose support.

Notifications You must be signed in to change notification settings

Jaypatelbond/CountryPicker

Repository files navigation

🌍 Country Picker Library for Android

License: MIT API Kotlin Compose

A beautiful, fully customizable country picker component for Android with Jetpack Compose support.

✨ Features

  • 🎨 Fully Customizable - Colors, fonts, shapes.
  • 🔍 Smart Search - Filter by name, code, or dial code.
  • 🌍 50+ Countries - Built-in list with flags.
  • 📱 Material Design 3 - Modern UI.
  • Lightweight - Pure Kotlin & Compose.

📦 Installation

Add to your module's build.gradle.kts:

dependencies {
    // For Jetpack Compose
    implementation("com.github.Jaypatelbond.CountryPicker:compose:v1.1.2")

    // For Views / Fragments
    implementation("com.github.Jaypatelbond.CountryPicker:view:v1.1.2")
    
    // Core (Data only)
    implementation("com.github.Jaypatelbond.CountryPicker:core:v1.1.2")
}

🚀 Quick Start (Compose)

@Composable
fun MyScreen() {
    var showPicker by remember { mutableStateOf(false) }
    var selectedCountry by remember { mutableStateOf<Country?>(null) }

    Button(onClick = { showPicker = true }) {
        Text("Select Country")
    }

    if (showPicker) {
        CountryPickerBottomSheet(
            onDismiss = { showPicker = false },
            onCountrySelected = { country ->
                selectedCountry = country
                showPicker = false
            }
        )
    }
}

🎨 Customization

Customize the look and feel easily:

CountryPickerBottomSheet(
    onDismiss = { showPicker = false },
    onCountrySelected = { /* ... */ },
    style = CountryPickerStyle(
        titleText = "Select Location",
        titleColor = Color(0xFF6200EE),
        searchHintText = "Search...",
        enableItemAnimation = true
    )
)

🎯 Filtering

You can show all countries, a specific list, or block certain ones.

// Show only specific countries
val europeanCountries = listOf(
    Country("France", "FR", "+33"),
    Country("Germany", "DE", "+49")
)

CountryPickerBottomSheet(
    // ...
    customCountryList = europeanCountries
)

📱 Legacy Support (Fragments/Views)

Click to expand Fragment implementation details

From Activity/Fragment

val picker = CountryPickerBottomSheetFragment().apply {
    onCountrySelectedListener = { country ->
        Toast.makeText(context, "Selected: ${country.name}", Toast.LENGTH_SHORT).show()
    }
}
picker.show(supportFragmentManager, "CountryPicker")

🤝 Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

📄 License

MIT License. See LICENSE for details.

About

A beautiful, fully customizable Country Picker for Android with Jetpack Compose support.

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages