Abhimanyu
10/22/2023, 4:14 AMsupportText
when using Material 3 OutlinedTextField
?@Composable
fun OutlinedTextFieldSupportTextSample() {
var text by remember {
mutableStateOf("")
}
Column(
horizontalAlignment = Alignment.CenterHorizontally,
) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.background(Color.LightGray)
)
OutlinedTextField(
value = text,
onValueChange = {
text = it
},
supportingText = {
AnimatedVisibility (text.isBlank()) {
Text("Text cannot be blank")
}
},
)
Box(
modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.background(Color.LightGray)
)
}
}
null
to the supportText
like this removes the space, but it does not animate.
supportingText = if (text.isBlank()) {
{
AnimatedVisibility(text.isBlank()) {
Text("Text cannot be blank")
}
}
} else {
null
},
Zach Klippenstein (he/him) [MOD]
10/23/2023, 3:21 AMAbhimanyu
10/23/2023, 5:14 AM