The solution I have so far is to use a Transparent
Color for the cursor.
I am looking for a better way to hide it if there is any.
cursorBrush = SolidColor(Transparent)
TextField should be focused, the keyboard should be open and the user should be able to type input.
The problem with this is I can still see the TextFieldCursorHandle
after entering text.
BasicTextField
you can hide the cursor using cursorBrush = SolidColor(Unspecified)
.TextField
you can use the attribute colors = TextFieldDefaults.textFieldColors(cursorColor = Color.Unspecified)
The TextFieldCursorHandle
and the selected text use the color provided by LocalTextSelectionColors.current
You override this color defining a custom TextSelectionColors
:
val customTextSelectionColors = TextSelectionColors(
handleColor = Color.Transparent,
backgroundColor = Color.Transparent
)
CompositionLocalProvider(LocalTextSelectionColors provides customTextSelectionColors) {
BasicTextField(
value = text,
onValueChange = {text = it},
cursorBrush = SolidColor(Unspecified)
)
TextField(
value = text,
onValueChange = {text = it},
colors = TextFieldDefaults.textFieldColors(cursorColor = Color.Unspecified)
)
}