PasskeyUsernameField

fun PasskeyUsernameField(value: String, onValueChange: (String) -> Unit, requestOptions: suspend () -> String, onSignedIn: (PasskeyAssertion) -> Unit, modifier: Modifier = Modifier, passkeys: Passkeys = rememberPasskeys(), label: String = "Username", onError: (PasskeyError) -> Unit = {}, enabled: Boolean = true)

A username text field that offers the user's passkeys as keyboard suggestions (passkey autofill).

While the field is focused and the platform supports it (PasskeyCapabilities.autofill: Android 15 / API 35+, iOS 16+), the field keeps a SignInMode.Autofill request open:

  • Android: the passkey appears as a suggestion chip in the keyboard. The request is anchored to the field's own view, so this also works inside a Dialog or ModalBottomSheet.

  • iOS: the passkey appears in the QuickType bar above the keyboard. The field is a native UITextField with the username content type, because iOS only offers passkeys for real UIKit username fields.

  • Other platforms: a plain Material 3 outlined text field; no request is made.

Picking a suggestion signs in and calls onSignedIn. Dismissing it is not an error: the field keeps offering passkeys, and tapping the field again brings the suggestion back. Losing focus or leaving composition withdraws the offer. Typing a username works as usual through value and onValueChange, so the field also serves the password or "continue with username" path.

Parameters

value

the text in the field.

onValueChange

called when the user edits the text.

requestOptions

fetches fresh WebAuthn request options JSON from your server (usually with an empty allowCredentials). Called for every new offer; the latest lambda is always used.

onSignedIn

called with the assertion to send to your server.

modifier

applied to the field.

passkeys

the passkeys implementation; defaults to rememberPasskeys. Pass a fake in previews and tests.

label

the field label.

onError

called when autofill can't work: PasskeyError.NotSupported, PasskeyError.Misconfigured or PasskeyError.InvalidOptions (reported once, then the field stops offering passkeys), or an unexpected error such as requestOptions throwing (the field retries on the next focus or tap). Dismissals are never reported.

enabled

whether the field can be edited and focused; no passkeys are offered while disabled.