AI CSS Animations

Dot to Underline Link Hover

A small dot sits under the middle of the link and stretches into a full underline with an elastic overshoot, thinning as it grows. A rounded clip-path inset morphs dot to pill.

Also known as: dot expands to underline, elastic underline hover, bouncy underline link.

HTML

<a class="hfx-link-dot-underline" href="#">Pricing</a>

CSS

.hfx-link-dot-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.5em;}
.hfx-link-dot-underline::after {
  content: "";
  position: absolute;
  left: -0.25em;
  right: -0.25em;
  bottom: 0.1em;
  height: 0.28em;
  background: var(--c);
  clip-path: inset(0 calc(50% - 0.14em) round 1em);
  transform-origin: bottom;
  transition: clip-path 0.55s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.35s ease;
}
.hfx-link-dot-underline:is(:hover, :focus-visible)::after {
  clip-path: inset(0 0.25em round 1em);
  transform: scaleY(0.45);
}

@media (prefers-reduced-motion: reduce) {
  .hfx-link-dot-underline, .hfx-link-dot-underline *, .hfx-link-dot-underline::before, .hfx-link-dot-underline::after, .hfx-link-dot-underline *::before, .hfx-link-dot-underline *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --hfx-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hfx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar hover effects

Underline Grow Link
Underline from Center Link
Highlighter Link
Slide Up Text Link