A translucent highlighter stroke fills in behind the text from left to right, like someone running a marker across it. Done with an animated background size.
Also known as: marker highlight hover, background fill link.
<a class="hfx-link-highlight" href="#">Why we built this</a>
.hfx-link-highlight {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
position: relative;
display: inline-block;
color: var(--c);
font: 600 1em system-ui, sans-serif;
text-decoration: none;
color: inherit;
background: linear-gradient(color-mix(in srgb, var(--c) 40%, transparent), color-mix(in srgb, var(--c) 40%, transparent)) no-repeat 0 100%;
background-size: 0% 45%;
transition: background-size 0.35s ease;}
.hfx-link-highlight:hover { background-size: 100% 45%; }
@media (prefers-reduced-motion: reduce) {
.hfx-link-highlight, .hfx-link-highlight *, .hfx-link-highlight::before, .hfx-link-highlight::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.