Compose Modifier

contentType

Set autofill hint with contentType.

AutofillableTextFieldWithAutofillModifier

@Sampled
@Composable
fun AutofillableTextFieldWithAutofillModifier() {
    TextField(
        state = rememberTextFieldState(),
        label = { Text("Enter your new username here.") },
        // Set the content type hint with the modifier extension.
        modifier = Modifier.contentType(ContentType.NewUsername),
    )
}

AutofillableTextFieldWithContentTypeSemantics

@Sampled
@Composable
fun AutofillableTextFieldWithContentTypeSemantics() {
    TextField(
        state = rememberTextFieldState(),
        label = { Text("Enter your new password here.") },
        // Set the content type hint with semantics.
        modifier = Modifier.semantics { contentType = ContentType.NewPassword },
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: