The arrow drops into the tray and fades, the tray gives a little under the weight, then a fresh arrow falls in from the top and settles. Loops for as long as you hover.
Also known as: download icon animation css, arrow down hover effect, download button icon.
<button class="hfx-download-icon-drop" aria-label="Download"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path class="hfx-download-icon-drop-tray" d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><g class="hfx-download-icon-drop-arrow"><path d="M12 3v12"/><path d="m7 10 5 5 5-5"/></g></svg></button>
.hfx-download-icon-drop {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
position: relative;
display: grid;
place-items: center;
width: 3.5em;
height: 3.5em;
padding: 0;
border: 0;
border-radius: 50%;
cursor: pointer;
border-radius: 0.85em;
background: color-mix(in srgb, var(--c) 12%, transparent);
color: var(--c);
transition: background-color 0.25s ease;}
.hfx-download-icon-drop svg {
width: 1.6em;
height: 1.6em;
}
.hfx-download-icon-drop-arrow,
.hfx-download-icon-drop-tray {
transform-box: view-box;
transform-origin: 50% 87.5%;
}
.hfx-download-icon-drop:is(:hover, :focus-visible) { background: color-mix(in srgb, var(--c) 20%, transparent); }
.hfx-download-icon-drop:is(:hover, :focus-visible) .hfx-download-icon-drop-arrow {
animation: hfx-download-icon-drop-fall 1.2s infinite;
}
.hfx-download-icon-drop:is(:hover, :focus-visible) .hfx-download-icon-drop-tray {
animation: hfx-download-icon-drop-give 1.2s infinite;
}
@keyframes hfx-download-icon-drop-fall {
0% { transform: translateY(0); opacity: 1; animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
32% { transform: translateY(30%); opacity: 0; }
33% { transform: translateY(-45%); opacity: 0; animation-timing-function: cubic-bezier(0.2, 0.8, 0.3, 1.25); }
75% { transform: translateY(0); opacity: 1; }
100% { transform: translateY(0); opacity: 1; }
}
@keyframes hfx-download-icon-drop-give {
0%, 22%, 100% { transform: scaleY(1); }
32% { transform: scaleY(0.72); animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
52% { transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
.hfx-download-icon-drop, .hfx-download-icon-drop *, .hfx-download-icon-drop::before, .hfx-download-icon-drop::after, .hfx-download-icon-drop *::before, .hfx-download-icon-drop *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--hfx-color on the element or a parent.
Currently previewing #3b82f6.--hfx-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.