A quick press on hover: the button dips to 85% and springs back as if tapped, then keeps a light tint while hovered. The keyframe has only a 50% stop, so it returns to rest on its own.
Also known as: hvr-push, button press on hover, tap animation css.
<button class="hfx-push"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>Add to list</button>
.hfx-push {
--c: var(--hfx-color, #3b82f6);
display: inline-flex;
align-items: center;
gap: 0.5em;
padding: 0.7em 1.6em;
border-radius: 0.5em;
font: 600 var(--hfx-size, 16px) system-ui, sans-serif;
cursor: pointer;
border: 2px solid var(--c);
background: transparent;
color: var(--c);
transition: background-color 0.25s ease;}
.hfx-push svg {
width: 1.1em;
height: 1.1em;
}
.hfx-push:is(:hover, :focus-visible) {
background: color-mix(in srgb, var(--c) 14%, transparent);
animation: hfx-push-press 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
@keyframes hfx-push-press {
50% { transform: scale(0.85); }
}
@media (prefers-reduced-motion: reduce) {
.hfx-push, .hfx-push *, .hfx-push::before, .hfx-push::after, .hfx-push *::before, .hfx-push *::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.