So, I had the similar problem that I wasn't satisfied with the defined condition of UnfocusedBorderThickness = 1.dp
with OutlinedTextField
.
I tried several options and the solution which worked for me is a Custom One. I am using BasicTextField
with OutlinedTextFieldDefaults.DecorationBox
and OutlinedTextFieldDefaults.ContainerBox
.
var searchText by rememberSaveable { mutableStateOf("") }
val interactionSource = remember { MutableInteractionSource() }
BasicTextField(
value = searchText,
singleLine = true,
interactionSource = interactionSource,
cursorBrush = SolidColor(Color.White),
onValueChange = { newText -> searchText = newText }
) { innerTextField ->
OutlinedTextFieldDefaults.DecorationBox(
value = searchText,
innerTextField = innerTextField,
enabled = true,
singleLine = true,
interactionSource = interactionSource,
visualTransformation = VisualTransformation.None,
placeholder = {
Text(
text = stringResource(R.string.text),
)
},
container = {
OutlinedTextFieldDefaults.ContainerBox(
enabled = true,
isError = false,
interactionSource = interactionSource,
colors = OutlinedTextFieldDefaults.colors(),
shape = RoundedCornerShape(Dimens.ActionButtonRadius),
focusedBorderThickness = 5.dp,
unfocusedBorderThickness = 5.dp
)
}
)
}