A closed eye with lashes that opens when checked: the upper lid flips up into an arch, the lashes tuck away and the pupil pops in. Pair it with a line of JS that flips the password field's type.
Also known as: show password checkbox css, eye icon toggle css, password visibility icon.
<label class="chk-eye-show-password">
<input type="checkbox">
<svg class="chk-eye-show-password-icon" viewBox="0 0 24 24" aria-hidden="true">
<path d="M2.5 12c2.4 4.2 5.6 6.3 9.5 6.3s7.1-2.1 9.5-6.3"/>
<path class="chk-eye-show-password-lid" d="M2.5 12c2.4-4.2 5.6-6.3 9.5-6.3s7.1 2.1 9.5 6.3"/>
<circle class="chk-eye-show-password-pupil" cx="12" cy="12" r="3.2"/>
<path class="chk-eye-show-password-lashes" d="M6.7 16.7l-1.3 2.1M12 18.3v2.5M17.3 16.7l1.3 2.1"/>
</svg>
<span class="chk-eye-show-password-text">Show password</span>
</label>.chk-eye-show-password {
--c: var(--chk-color, #3b82f6);
font-size: var(--chk-size, 24px);
position: relative;
display: inline-flex;
align-items: center;
gap: 0.6em;
line-height: 1.3;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.chk-eye-show-password input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.chk-eye-show-password-icon {
flex: none;
width: 1.6em;
height: 1.6em;
overflow: visible;
border-radius: 0.3em;
color: color-mix(in srgb, currentColor 70%, transparent);
fill: none;
stroke: currentColor;
stroke-width: 1.8;
stroke-linecap: round;
stroke-linejoin: round;
transition: color 0.25s ease;
}
.chk-eye-show-password-lid {
transform-box: view-box;
transform-origin: 50% 50%;
transform: scaleY(-1);
transition: transform 0.35s cubic-bezier(0.5, 0, 0.3, 1.3);
}
.chk-eye-show-password-pupil {
fill: currentColor;
stroke: none;
transform-box: fill-box;
transform-origin: center;
transform: scale(0);
transition: transform 0.2s ease-in;
}
.chk-eye-show-password-lashes {
transform-box: fill-box;
transform-origin: 50% 0;
transition: transform 0.25s ease 0.1s, opacity 0.2s ease 0.1s;
}
.chk-eye-show-password-text {
transition: color 0.25s ease;
}
.chk-eye-show-password input:checked ~ .chk-eye-show-password-text {
color: var(--c);
}
.chk-eye-show-password:hover .chk-eye-show-password-icon {
color: var(--c);
}
.chk-eye-show-password input:checked + .chk-eye-show-password-icon {
color: var(--c);
}
.chk-eye-show-password input:checked + .chk-eye-show-password-icon .chk-eye-show-password-lid {
transform: scaleY(1);
}
.chk-eye-show-password input:checked + .chk-eye-show-password-icon .chk-eye-show-password-pupil {
transform: scale(1);
transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s;
}
.chk-eye-show-password input:checked + .chk-eye-show-password-icon .chk-eye-show-password-lashes {
opacity: 0;
transform: scaleY(0);
transition-delay: 0s;
}
.chk-eye-show-password input:focus-visible + .chk-eye-show-password-icon {
outline: 0.12em solid var(--c);
outline-offset: 0.18em;
}
@media (prefers-reduced-motion: reduce) {
.chk-eye-show-password, .chk-eye-show-password *, .chk-eye-show-password::before, .chk-eye-show-password::after, .chk-eye-show-password *::before, .chk-eye-show-password *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--chk-color on the element or a parent.
Currently previewing #3b82f6.--chk-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 24px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.