What’s the best way to center a label vertically i...
# compose-desktop
s
What’s the best way to center a label vertically in an
OutlinedTextField
. I can’t seem to find a good way.
Copy code
val userState = remember { mutableStateOf(TextFieldValue()) }
        OutlinedTextField(
            value = userState.value,
            onValueChange = { userState.value = it },
            label = {
                Text("User")
            },
        )

        Spacer(Modifier.height(10.dp))

        val passwordState = remember { mutableStateOf(TextFieldValue()) }
        val hidePassword = remember { mutableStateOf(true) }
        OutlinedTextField(
            value = passwordState.value,
            onValueChange = { passwordState.value = it },
            label = { Text("Password") },
            visualTransformation = if (hidePassword.value) PasswordVisualTransformation() else VisualTransformation.None,
            keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
        )
k
File a bug if
OutlinedTextField
is not up to the Material Design spec from https://material.io/components/text-fields#outlined-text-field
s
d
Not sure about compose desktop but on compose for android you'd have to set the parameter
singleLine
to true for the label to be centered
s
Thanks @Denis Ismailaj . That was the problem. Setting
singleLine = true
fixes it. Closing the ticket.