CountrySelector

fun CountrySelector(selectedCountry: Country?, onCountrySelected: (Country) -> Unit, modifier: Modifier = Modifier, config: CountryPickerConfig = CountryPickerDefaults.config(), variant: CountrySelectorVariant = CountrySelectorVariant.Elevated, enabled: Boolean = true, state: CountrySelectorState = CountrySelectorState.Default, label: UiText? = UiText.resource(Res.string.ccp_country_of_residence), placeholder: UiText? = UiText.resource(Res.string.ccp_select_country_placeholder), labelMode: InputLabelMode = InputLabelMode.Floating, supportingContent: CountrySupportingContent = CountrySupportingContent.None, supportingText: UiText? = null, errorText: UiText? = null, successText: UiText? = null, required: Boolean = false, sheetTitle: UiText = UiText.resource(Res.string.ccp_select_country), sheetSubtitle: UiText? = UiText.resource(Res.string.ccp_select_country_subtitle), recentCountryStore: RecentCountryStore = NoOpRecentCountryStore, detector: CountryDetector? = null, detectionBehavior: CountryDetectionBehavior = CountryDetectionBehavior.ShowBadge, repository: CountryRepository = CountryRepository.Default, style: CountryPickerStyle = CountryPickerTheme.style, flagContent: @Composable (Country) -> Unit? = null, trailingContent: @Composable () -> Unit? = null, selectorContent: @Composable RowScope.(Country?) -> Unit? = null, listItemContent: @Composable (CountryListItemScope) -> Unit? = null, emptyContent: @Composable (String) -> Unit? = null)(source)

A country field that opens the picker.

Controlled component

selectedCountry is the source of truth and the selector never changes it on its own — selection arrives through onCountrySelected. Hoist it in the caller:

var country by rememberSaveable { mutableStateOf<Country?>(null) }
CountrySelector(selectedCountry = country, onCountrySelected = { country = it })

Appearance

variant chooses the footprint — a full field, a rich card, or a compact pill. Colors, flags, shapes and the picker's own presentation come from style (by default the nearest CountryPickerTheme).

Parameters

config

Which countries are offered and how selection behaves.

enabled

Convenience for state = Disabled. When false, state is ignored.

state

Interaction and validation state.

label

Field label. The pill variants have no room for one; it is still announced.

placeholder

Shown while no country is selected.

labelMode

Show the label, or keep it for accessibility only.

supportingContent

The ISO and/or dial code under the country name in the field.

supportingText

Helper text below the field, replaced by errorText or successText in those states.

required

Marks the label and the accessibility description as required.

recentCountryStore

Recents persistence. The default persists nothing.

detector

Country detection, or null to disable it.

detectionBehavior

What to do with a detection result.

flagContent

Replaces the flag renderer everywhere this selector draws one.

trailingContent

Replaces the chevron, spinner and state icons.

selectorContent

Replaces the field's inner layout, keeping its click and accessibility behaviour — the escape hatch for a bespoke design.

listItemContent

Replaces the picker's row renderer.

emptyContent

Replaces the picker's no-results state.