The border thickens inward like an iris closing until the box is solid, then the tick drops in with a bounce. The fill is one inset box-shadow whose spread grows past half the box width.
Also known as: border fill checkbox, css checkbox fill animation, inset shadow checkbox.
<label class="chk-outline-to-solid-checkbox">
<input type="checkbox">
<span class="chk-outline-to-solid-checkbox-box">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5.5 12.5l4 4L18.5 7.5"/></svg>
</span>
Use my location
</label>.chk-outline-to-solid-checkbox {
--c: var(--chk-color, #3b82f6);
font-size: var(--chk-size, 24px);
position: relative;
display: inline-flex;
align-items: center;
gap: 0.6em;
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
line-height: 1.3;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.chk-outline-to-solid-checkbox input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.chk-outline-to-solid-checkbox-box {
box-sizing: border-box;
display: grid;
place-items: center;
flex: none;
width: 1.375em;
height: 1.375em;
border: 0.125em solid color-mix(in srgb, currentColor 38%, transparent);
border-radius: 0.35em;
box-shadow: inset 0 0 0 0 var(--c);
transition: box-shadow 0.3s cubic-bezier(0.65, 0, 0.35, 1) 0.12s, border-color 0.3s ease 0.12s;
}
.chk-outline-to-solid-checkbox-box svg {
display: block;
fill: none;
stroke-linecap: round;
stroke-linejoin: round;
width: 0.9em;
height: 0.9em;
stroke: #fff;
stroke-width: 3.2;
opacity: 0;
transform: translateY(-0.4em) scale(0.8);
transition: opacity 0.12s ease, transform 0.15s ease-in;
}
.chk-outline-to-solid-checkbox input:checked + .chk-outline-to-solid-checkbox-box {
border-color: var(--c);
box-shadow: inset 0 0 0 0.6em var(--c);
transition: box-shadow 0.35s cubic-bezier(0.65, 0, 0.35, 1), border-color 0.15s ease;
}
.chk-outline-to-solid-checkbox input:checked + .chk-outline-to-solid-checkbox-box svg {
opacity: 1;
transform: none;
transition: opacity 0.15s ease 0.28s, transform 0.45s cubic-bezier(0.34, 1.8, 0.64, 1) 0.28s;
}
.chk-outline-to-solid-checkbox input:focus-visible + .chk-outline-to-solid-checkbox-box {
outline: 0.125em solid var(--c);
outline-offset: 0.18em;
}
@media (prefers-reduced-motion: reduce) {
.chk-outline-to-solid-checkbox, .chk-outline-to-solid-checkbox *, .chk-outline-to-solid-checkbox::before, .chk-outline-to-solid-checkbox::after, .chk-outline-to-solid-checkbox *::before, .chk-outline-to-solid-checkbox *::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.