How to Enable TextField Auto Correct in Android Jetpack Compose

By Mohammed Rashid •  November 17th, 2022 • 

Auto-correct is usually a useful feature when you are typing long-form content. But it can be disturbing also, especially when the user types short texts such as username, name, etc. Let’s learn how to enable auto correct feature in jetpack Compose.

You can use KeyboardOptions associated with TextField to enable or disable the autocorrect feature.

package com.example.myapplication

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.myapplication.ui.theme.MyApplicationTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        setContent {
            MyApplicationTheme {
                    color = MaterialTheme.colors.background
                ) {

fun Example() {
    var value by remember { mutableStateOf("") }
        value = value,
        onValueChange = { value = it },
        keyboardOptions = KeyboardOptions(autoCorrect = true),
        label = { Text("Enter text") },
        maxLines = 2,
        modifier = Modifier.padding(20.dp)

@Preview(showBackground = true)
fun DefaultPreview() {
    MyApplicationTheme {

That’s how you add the auto-correct feature in Jetpack Compose.

Mohammed Rashid

Keep Reading