A rounded square that melts into a circle as it fills, with the tick twisting into place a beat later. The corner radius transitions between two percentages, so it morphs smoothly at any size.
Also known as: morphing checkbox css, rounded checkbox animation, shape morph checkbox.
<label class="chk-square-to-circle-checkbox">
<span class="chk-square-to-circle-checkbox-box">
<input type="checkbox">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 12.5l4 4L18 8.5"/></svg>
</span>
Keep me posted
</label>.chk-square-to-circle-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-square-to-circle-checkbox-box {
position: relative;
display: grid;
place-items: center;
flex: none;
}
.chk-square-to-circle-checkbox input {
appearance: none;
-webkit-appearance: none;
box-sizing: border-box;
grid-area: 1 / 1;
width: 1.375em;
height: 1.375em;
margin: 0;
font: inherit;
background: transparent;
border: 0.125em solid color-mix(in srgb, currentColor 38%, transparent);
border-radius: 18%;
cursor: pointer;
transition: border-radius 0.4s cubic-bezier(0.34, 1.3, 0.64, 1), background-color 0.25s ease, border-color 0.25s ease;
}
.chk-square-to-circle-checkbox svg {
display: block;
fill: none;
stroke-linecap: round;
stroke-linejoin: round;
grid-area: 1 / 1;
width: 0.875em;
height: 0.875em;
stroke: #fff;
stroke-width: 3.2;
pointer-events: none;
transform: rotate(-45deg) scale(0);
transition: transform 0.15s ease-in;
}
.chk-square-to-circle-checkbox input:checked {
border-radius: 50%;
background: var(--c);
border-color: var(--c);
}
.chk-square-to-circle-checkbox input:checked + svg {
transform: rotate(0deg) scale(1);
transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s;
}
.chk-square-to-circle-checkbox input:focus-visible {
outline: 0.125em solid var(--c);
outline-offset: 0.18em;
}
@media (prefers-reduced-motion: reduce) {
.chk-square-to-circle-checkbox, .chk-square-to-circle-checkbox *, .chk-square-to-circle-checkbox::before, .chk-square-to-circle-checkbox::after, .chk-square-to-circle-checkbox *::before, .chk-square-to-circle-checkbox *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}The same effect using Tailwind utility classes. No custom CSS or config needed.
<label class="inline-flex cursor-pointer items-center gap-2.5">
<span class="relative grid place-items-center">
<input type="checkbox" class="peer h-[22px] w-[22px] cursor-pointer appearance-none rounded-[18%] border-2 border-gray-400 transition-[border-radius,background-color,border-color] duration-[400ms] ease-[cubic-bezier(.34,1.3,.64,1)] checked:rounded-[50%] checked:border-blue-500 checked:bg-blue-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500">
<svg viewBox="0 0 24 24" aria-hidden="true" class="pointer-events-none absolute h-3.5 w-3.5 -rotate-45 scale-0 fill-none stroke-white stroke-[3.2] transition-transform duration-150 [stroke-linecap:round] [stroke-linejoin:round] peer-checked:rotate-0 peer-checked:scale-100 peer-checked:delay-100 peer-checked:duration-300 peer-checked:ease-[cubic-bezier(.34,1.56,.64,1)]"><path d="M6 12.5l4 4L18 8.5"/></svg>
</span>
Keep me posted
</label>--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.