Compose Modifier

contentType

Set autofill hint with [contentType].

AutofillableTextFieldWithAutofillModifier

@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

@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 },
    )
}