JetpackPasswordFiled

fun JetpackPasswordFiled(value: String, onValueChange: (String) -> Unit, label: @Composable () -> Unit, leadingIcon: @Composable () -> Unit, modifier: Modifier = Modifier, errorMessage: String? = null)

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

value

The current text value of the password field.

onValueChange

The callback invoked when the text value changes.

label

A composable function that represents the label of the password field.

leadingIcon

A composable function that represents the leading icon of the password field.

modifier

The modifier for this password field.

errorMessage

The error message to display below the password field. Shows red border when not null.