PhoneNumberInput

fun PhoneNumberInput(modifier: Modifier = Modifier, state: PhoneState = rememberPhoneState(), phoneHint: String = "Enter phone", label: String? = "Phone number", onPhoneValueChange: (formatedPhone: String, unFormatedPhone: String, valid: Boolean) -> Unit = { _, _, _ -> }, onValueChange: (Phone) -> Unit = {}, value: String = "", setCountry: String? = null, countriesToShow: List<String> = emptyList(), countriesExclude: List<String> = emptyList(), pinnedCountries: List<String> = emptyList(), isError: Boolean = false, errorMessage: String? = null, colors: CCPColors = CCPDefaults.colors(), ccpConfig: CCPConfig = CCPDefaults.defaultConfig(), onDone: () -> Unit = {})(source)

A highly customizable international phone number input component with country selection.

State is managed by PhoneState, which can be hoisted to the caller for external control:

val phoneState = rememberPhoneState()
PhoneNumberInput(state = phoneState, ...)
// Elsewhere: phoneState.clearPhone(), phoneState.isValid, phoneState.toPhone()

Parameters

modifier

Modifier applied to the outermost layout (Column containing field + error text).

state

Hoistable state holder. Defaults to an internal rememberPhoneState.

phoneHint

Placeholder text shown when the input is empty.

label

Floating label shown notched into the field's outline. Only rendered when CCPConfig.showLabel is true (off by default, matching the field's previous no-label look) — pass both to give the field a label.

onPhoneValueChange

Deprecated – use onValueChange.

onValueChange

Callback invoked on every change, providing a Phone snapshot.

value

Optional initial phone number (E.164 or local format).

setCountry

Optional ISO code or country name to preselect (e.g. "KE", "Kenya").

countriesToShow

Whitelist of ISO codes shown in the country selector. Empty = all.

countriesExclude

Blacklist of ISO codes hidden from the country selector.

pinnedCountries

ISO codes pinned to a "Suggested" section at the top of the sheet.

isError

Whether to show the error border and errorMessage.

errorMessage

Text displayed below the field when isError is true.

colors

Color configuration.

ccpConfig

Behavior and UI configuration.

onDone

Called when the keyboard "Done" action is pressed and the number is valid.