Jetpack Compose how to remove EditText/TextField underline and keep cursor?

You can define these attributes to apply a Transparent color: focusedIndicatorColor unfocusedIndicatorColor disabledIndicatorColor Something like: TextField( //.. colors = TextFieldDefaults.textFieldColors( textColor = Color.Gray, disabledTextColor = Color.Transparent, backgroundColor = Color.White, focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent, disabledIndicatorColor = Color.Transparent ) ) Starting with 1.2.0 you can also use the new OutlinedTextFieldDecorationBox together with BasicTextField customizing the … Read more

Exposed drop-down menu for jetpack compose

The M2 (starting from the version 1.1.0-alpha06) and M3 have the implementation of ExposedDropdownMenu based on ExposedDropdownMenuBox with TextField and DropdownMenu inside. Something like: val options = listOf(“Option 1”, “Option 2”, “Option 3”, “Option 4”, “Option 5”) var expanded by remember { mutableStateOf(false) } var selectedOptionText by remember { mutableStateOf(options[0]) } ExposedDropdownMenuBox( expanded = expanded, … Read more

Request Focus on TextField in jetpack compose

Posting an updated Answer to the question (APIs were renamed in Compose Beta) @Composable fun AutoFocusingText() { var value by mutableStateOf(“Enter Text”) val focusRequester = remember { FocusRequester() } TextField( value = value, onValueChange = { value = it }, modifier = Modifier.focusRequester(focusRequester) ) LaunchedEffect(Unit) { focusRequester.requestFocus() } }

How to close the virtual keyboard from a Jetpack Compose TextField?

You can use the LocalSoftwareKeyboardController class to control the current software keyboard and then use the hide method: var text by remember { mutableStateOf(TextFieldValue(“Text”)) } val keyboardController = LocalSoftwareKeyboardController.current TextField( value = text, onValueChange = { text = it }, label = { Text(“Label”) }, keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), keyboardActions = KeyboardActions( onDone = … Read more