A task card that completes in one gesture: a tint sweeps across the row, the round check squashes and bounces, the text slides aside and a Done pill pops in. Every piece reverses on uncheck.
Also known as: todo item complete animation, task list checkbox css, complete task animation.
<label class="chk-todo-task-card">
<input type="checkbox">
<span class="chk-todo-task-card-sweep"></span>
<span class="chk-todo-task-card-dot"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6.5 12.5l3.5 3.5 7.5-7.5"/></svg></span>
<span class="chk-todo-task-card-body">
<span class="chk-todo-task-card-title">Book flights</span>
<span class="chk-todo-task-card-meta">Today, 5 pm</span>
</span>
<span class="chk-todo-task-card-done" aria-hidden="true">Done</span>
</label>.chk-todo-task-card {
--c: var(--chk-color, #3b82f6);
font-size: var(--chk-size, 24px);
position: relative;
isolation: isolate;
display: flex;
align-items: center;
gap: 0.7em;
width: 13em;
padding: 0.7em 0.9em;
border: 0.07em solid color-mix(in srgb, currentColor 16%, transparent);
border-radius: 0.8em;
overflow: hidden;
line-height: 1.25;
cursor: pointer;
-webkit-user-select: none;
user-select: none;}
.chk-todo-task-card input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.chk-todo-task-card-sweep {
position: absolute;
inset: 0;
z-index: -1;
background: color-mix(in srgb, var(--c) 12%, transparent);
transform: scaleX(0);
transform-origin: left;
transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
.chk-todo-task-card-dot {
display: grid;
place-items: center;
flex: none;
width: 1.35em;
height: 1.35em;
border: 0.12em solid color-mix(in srgb, currentColor 38%, transparent);
border-radius: 50%;
transition: background-color 0.25s ease, border-color 0.25s ease;
}
.chk-todo-task-card-dot svg {
width: 0.95em;
height: 0.95em;
fill: none;
stroke: #fff;
stroke-width: 3.2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 17;
stroke-dashoffset: 17;
transition: stroke-dashoffset 0.15s ease-in;
}
.chk-todo-task-card-body {
display: grid;
flex: 1;
min-width: 0;
transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}
.chk-todo-task-card-title {
font-weight: 600;
}
.chk-todo-task-card-meta {
font-size: 0.72em;
opacity: 0.6;
}
.chk-todo-task-card-done {
flex: none;
padding: 0.25em 0.65em;
border-radius: 1em;
background: var(--c);
color: #fff;
font-size: 0.68em;
font-weight: 600;
opacity: 0;
transform: translateX(0.8em) scale(0.6);
transition: opacity 0.2s ease, transform 0.3s ease;
}
.chk-todo-task-card input:checked ~ .chk-todo-task-card-sweep {
transform: scaleX(1);
transition-duration: 0.5s;
}
.chk-todo-task-card input:checked ~ .chk-todo-task-card-dot {
background: var(--c);
border-color: var(--c);
animation: chk-todo-task-card-pop 0.5s ease-out;
}
.chk-todo-task-card input:checked ~ .chk-todo-task-card-dot svg {
stroke-dashoffset: 0;
transition: stroke-dashoffset 0.25s ease-out 0.15s;
}
.chk-todo-task-card input:checked ~ .chk-todo-task-card-body {
transform: translateX(0.25em);
opacity: 0.55;
}
.chk-todo-task-card input:checked ~ .chk-todo-task-card-done {
opacity: 1;
transform: none;
transition: opacity 0.2s ease 0.2s, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s;
}
.chk-todo-task-card input:focus-visible ~ .chk-todo-task-card-dot {
outline: 0.12em solid var(--c);
outline-offset: 0.18em;
}
@keyframes chk-todo-task-card-pop {
0% { transform: scale(1); }
30% { transform: scale(0.72, 0.66); }
60% { transform: scale(1.18); }
80% { transform: scale(0.95); }
100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
.chk-todo-task-card, .chk-todo-task-card *, .chk-todo-task-card::before, .chk-todo-task-card::after, .chk-todo-task-card *::before, .chk-todo-task-card *::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.