0

I want to disable capitalization on my OutlinedTextField that i want to be of an email type. Obviously this email type should have capitalization disabled. So here is what I tried and with no effect (still first letter starts with uppercase):

@Composable
fun FormTextFieldsLogin() {
    OutlinedTextField(keyboardOptions = KeyboardOptions(
        capitalization = KeyboardCapitalization.None,
        keyboardType = KeyboardType.Email,
        imeAction = ImeAction.Next
    ), value = etEmail, onValueChange = { etEmail = it }, label = { Text("Email") }, leadingIcon = { Image(painter = painterResource(id = R.drawable.person), contentDescription = "email") })
}
2
  • The keyboard option capitalization controls the automatic capitalization. This still means the user can capitalize anything they want, it just won't happen autoatically when None is specified. Further more, this ist just a request, the keyboard can ignore this request, so you don't even have a guarantee anything will happen at all using this option. If you want to force it, you need a different approach by converting everything that was entered after the fact. Please edit the question to specify what you really want to achieve. Commented Apr 30 at 17:15
  • 1
    But keep in mind, technically, email addresses are case sensitive. Although most providers will accept either case and ignore any capitalization. There is no hard, technical guarantee, though. Commented Apr 30 at 17:15

1 Answer 1

0

I had a similar issue where typing an email like [email protected] would automatically change to [email protected] after typing the . character. This happened because the keyboard was applying autocorrect behavior.

To fix it, I disabled autocorrect explicitly using autoCorrectEnabled = false in KeyboardOptions. Here's the updated code:

OutlinedTextField(
            value = email,
            onValueChange = onEmailChange,
            label = { Text("Email") },
            keyboardOptions = KeyboardOptions(
                keyboardType = KeyboardType.Email,
                imeAction = ImeAction.Next,
                capitalization = KeyboardCapitalization.None,
                autoCorrectEnabled = false, // 👈 Important line
            ),
            modifier = Modifier.fillMaxWidth()
                .semantics { contentType = ContentType.EmailAddress }

        )
Sign up to request clarification or add additional context in comments.

1 Comment

Doesn't work, still first letter is capitalized, but thanks anyway. I will give a like.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.