A flat hairline under the link wipes into a wavy line that keeps flowing sideways while hovered. The wave is a tiny SVG used as a CSS mask, so it takes the accent color.
Also known as: wavy underline css, squiggly underline hover, animated wave underline.
<a class="hfx-link-wavy-underline" href="#">Explore the map</a>
.hfx-link-wavy-underline {
--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;
padding-bottom: 0.4em;}
.hfx-link-wavy-underline::before,
.hfx-link-wavy-underline::after {
content: "";
position: absolute;
left: 0;
right: 0;
}
.hfx-link-wavy-underline::before {
bottom: 0.18em;
height: 0.09em;
border-radius: 1em;
background: color-mix(in srgb, var(--c) 45%, transparent);
transform-origin: right;
transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}
.hfx-link-wavy-underline::after {
bottom: 0;
height: 0.45em;
background: var(--c);
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 10'%3E%3Cpath d='M0 5Q5-1 10 5T20 5' fill='none' stroke='%23000' stroke-width='2.2'/%3E%3C/svg%3E") 0 0 / 0.9em 0.45em repeat-x;
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 10'%3E%3Cpath d='M0 5Q5-1 10 5T20 5' fill='none' stroke='%23000' stroke-width='2.2'/%3E%3C/svg%3E") 0 0 / 0.9em 0.45em repeat-x;
clip-path: inset(0 100% 0 0);
transition: clip-path 0.45s cubic-bezier(0.65, 0, 0.35, 1);
animation: hfx-link-wavy-underline-flow 0.9s linear infinite paused;
}
.hfx-link-wavy-underline:is(:hover, :focus-visible)::before { transform: scaleX(0); }
.hfx-link-wavy-underline:is(:hover, :focus-visible)::after {
clip-path: inset(0);
animation-play-state: running;
}
@keyframes hfx-link-wavy-underline-flow {
to {
-webkit-mask-position: 0.9em 0;
mask-position: 0.9em 0;
}
}
@media (prefers-reduced-motion: reduce) {
.hfx-link-wavy-underline, .hfx-link-wavy-underline *, .hfx-link-wavy-underline::before, .hfx-link-wavy-underline::after, .hfx-link-wavy-underline *::before, .hfx-link-wavy-underline *::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.