I'm trying to show a password strength as a user is typing his password.
The strength indication divs (.strengthClass and .rules-details) should show up only when the user types his password (ie. when .password-input on focus)
I tried the CSS code below to test with .strengthClass but it's not working.
How can I overcome this with only CSS ?
HTML:
<StrengthStyled className="password-rules">
<Flex justifyContent="center" className={`strengthClass strength-${strengthClass.id} value-${strengthClass.value}`} my={10}>
<span>
{
strengthClass.value === 'Weak' ?
'Faible'
: strengthClass.value === 'Too weak' ?
'Très faible'
: strengthClass.value === 'Medium' ?
'Moyen'
: strengthClass.value === 'Strong' ?
'Fort'
: null
}
</span>
</Flex>
<Box className="rules-details">
Règles du mot de passe:
<ul>
<li>Doit contenir au moins 1 majuscule</li>
<li>Doit contenir au moins 1 minuscule</li>
<li>Doit contenir au moins 1 chiffre</li>
<li>Doit contenir au moins 1 caractère spécial</li>
<li>Doit contenir au moins 10 caractères</li>
</ul>
</Box>
</StrengthStyled>
CSS:
.strengthClass{
max-width: 200px;
height: 30px;
padding: 5px;
font-size: 13px;
font-weight: 600;
border: 1px solid transparent;
border-radius: 25px;
background-color: #FF68A7;
display: none;
span{
color: white;
text-align: center;
}
}
.rules-details{
display: none;
}
.password-input:focus + .strengthClass{
display: block;
}