How change OutlineTextField border width in Android Jetpack Compose?

Viewed 1320

My code:

OutlinedTextField(
     value = state.value,
     onValueChange = { state.value = it },
     modifier = Modifier.fillMaxWidth().padding(start = 30.dp, end = 30.dp),
     label = { Text(text = "Something", fontSize = 14.sp) },
     shape = RoundedCornerShape(12.dp),
)

I want to increase the border width so that the colors focusedBorderColor, disabledBorderColor are supported.

1 Answers

Outline border is defined as a constant value in OutlinedTextField.

private val IndicatorUnfocusedWidth = 1.dp
private val IndicatorFocusedWidth = 2.dp

There is no direct way to override these values.

So, you have to create complete custom TextField Composables if you need to achieve dynamic border width.

You can copy-paste the complete code in OutlinedTextField.kt and TextFieldImpl.kt and modify them as required to create the custom Composables.

Related