You can use use it directly if you don't have any other composable below the Password field and If you have then You can show that view as persistant popup or you can bind it with your content in box
Output:

Here is the composable you are looking for
@Composable
fun PasswordTextFieldWithRequirement() {
var password by remember { mutableStateOf("") }
var isFocused by remember { mutableStateOf(false) }
val focusRequester = remember { FocusRequester() }
val interactionSource = remember { MutableInteractionSource() }
val textFieldSize = remember { mutableStateOf(IntSize.Zero) }
val passwordRequirements = listOf(
"At least 8 characters" to { password.length >= 8 },
"Contains a number" to { password.any { it.isDigit() } },
"Contains an uppercase letter" to { password.any { it.isUpperCase() } },
"Contains a special character" to {
password.any { "!@#$%^&*()_+-=[]{}|;:',.<>?/".contains(it) }
}
)
val textFieldModifier = Modifier.onGloballyPositioned { layoutCoordinates ->
textFieldSize.value = layoutCoordinates.size
}
LaunchedEffect(interactionSource) {
interactionSource.interactions.collect { interaction ->
when (interaction) {
is FocusInteraction.Focus -> isFocused = true
is FocusInteraction.Unfocus -> isFocused = false
}
}
}
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
) {
OutlinedTextField(
value = password,
onValueChange = { password = it },
label = { Text("Password") },
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Password),
interactionSource = interactionSource,
modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequester)
.then(textFieldModifier)
)
if (isFocused) {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(top = 8.dp)
.shadow(8.dp, shape = RoundedCornerShape(8.dp))
.background(MaterialTheme.colorScheme.surface)
.border(1.dp, MaterialTheme.colorScheme.primary, RoundedCornerShape(8.dp))
.padding(16.dp)
) {
Column {
Text(text = "Password Requirements", fontWeight = FontWeight.Bold)
Spacer(modifier = Modifier.height(8.dp))
passwordRequirements.forEach { (requirement, isValid) ->
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(
imageVector = if (isValid()) Icons.Default.Check else Icons.Default.Close,
contentDescription = null,
tint = if (isValid()) Color(0xFF228B22) else Color.Red
)
Spacer(modifier = Modifier.width(8.dp))
Text(requirement, color = if (isValid()) Color(0xFF228B22) else Color.Red)
}
}
}
}
}
}
}
PopUp - Position Provider!