JetpackPasswordFiled
A Jetpack Compose password field with visibility toggle and error message display.
This component automatically provides:
Password masking: Text is hidden by default with PasswordVisualTransformation
Visibility toggle: Trailing icon button to show/hide password
Keyboard type: Automatically sets keyboard type to Password
Error handling: Red border and error message when errorMessage is not null
State preservation: Password visibility state survives configuration changes
Usage example:
var password by remember { mutableStateOf("") }
var passwordError by remember { mutableStateOf<String?>(null) }
JetpackPasswordFiled(
value = password,
onValueChange = { password = it },
label = { Text("Password") },
leadingIcon = { Icon(Icons.Default.Lock, contentDescription = null) },
errorMessage = passwordError,
modifier = Modifier.fillMaxWidth(),
)Parameters
The current text value of the password field.
The callback invoked when the text value changes.
A composable function that represents the label of the password field.
A composable function that represents the leading icon of the password field.
The modifier for this password field.
The error message to display below the password field. Shows red border when not null.