A double beat, a small lub and a bigger dub, then a rest, looping like a pulse. Good for a like button, a live badge or a health stat. Each beat rises fast and eases back down.
Also known as: heartbeat animation css, heart beat pulse, lub dub animation.
<div class="kfa-heartbeat"><svg class="kfa-heartbeat-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 20.4 3.6 12.4a5.1 5.1 0 0 1 8.4-6.1 5.1 5.1 0 0 1 8.4 6.1Z" fill="currentColor"/></svg></div>
.kfa-heartbeat {
--c: var(--kfa-color, #3b82f6);
font-size: var(--kfa-size, 16px);
display: grid;
place-items: center;
width: 5.5em;
height: 5.5em;
border-radius: 1em;
background: var(--c);
color: #fff;
font-family: system-ui, sans-serif;
font-weight: 700;
box-shadow: 0 0.6em 1.4em -0.6em color-mix(in srgb, var(--c) 70%, transparent);
animation: kfa-heartbeat-beat 1.5s infinite;
}
.kfa-heartbeat-icon {
width: 2.6em;
height: 2.6em;
}
@keyframes kfa-heartbeat-beat {
0% { transform: scale(1); animation-timing-function: cubic-bezier(0.2, 0, 0.4, 1); }
10% { transform: scale(1.14); animation-timing-function: cubic-bezier(0.5, 0, 0.6, 1); }
20% { transform: scale(1.02); animation-timing-function: cubic-bezier(0.2, 0, 0.4, 1); }
30% { transform: scale(1.24); animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
50%, 100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
.kfa-heartbeat, .kfa-heartbeat *, .kfa-heartbeat::before, .kfa-heartbeat::after, .kfa-heartbeat *::before, .kfa-heartbeat *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--kfa-color on the element or a parent.
Currently previewing #3b82f6.--kfa-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.