A solid block sweeps across the link from the left, covers it for a beat and leaves to the right, and the text underneath has changed color. One keyframe with a mid-way origin flip.
Also known as: block reveal link, color block wipe link, swipe through highlight.
<a class="hfx-link-block-swipe" href="#">Selected work</a>
.hfx-link-block-swipe {
--c: var(--hfx-color, #3b82f6);
position: relative;
display: inline-block;
color: var(--c);
font: 600 calc(var(--hfx-size, 16px) * 1.25)/1.3 system-ui, sans-serif;
text-decoration: none;
color: inherit;
transition: color 0.3s ease;}
.hfx-link-block-swipe::before {
content: "";
position: absolute;
inset: -0.05em -0.15em;
background: var(--c);
transform: scaleX(0);
transform-origin: left;
}
.hfx-link-block-swipe:is(:hover, :focus-visible) {
color: var(--c);
transition: color 0s 0.3s;
}
.hfx-link-block-swipe:is(:hover, :focus-visible)::before {
animation: hfx-link-block-swipe-pass 0.65s cubic-bezier(0.7, 0, 0.3, 1);
}
@keyframes hfx-link-block-swipe-pass {
0% { transform: scaleX(0); transform-origin: left; }
45% { transform: scaleX(1); transform-origin: left; }
55% { transform: scaleX(1); transform-origin: right; }
100% { transform: scaleX(0); transform-origin: right; }
}
@media (prefers-reduced-motion: reduce) {
.hfx-link-block-swipe, .hfx-link-block-swipe *, .hfx-link-block-swipe::before, .hfx-link-block-swipe::after, .hfx-link-block-swipe *::before, .hfx-link-block-swipe *::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.