AI CSS Animations

Pagination Hover Effect

Page numbers where hovering draws a ring around the number clockwise and the arrows nudge outward. The ring is a conic mask whose angle is a registered @property, so it transitions.

Also known as: pagination css hover, page numbers hover animation, pager hover ring.

HTML

<nav class="hfx-nav-pagination-ring" aria-label="Pagination">
  <a href="#" aria-label="Previous page"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg></a>
  <a href="#">1</a>
  <a href="#" aria-current="page">2</a>
  <a href="#">3</a>
  <a href="#">4</a>
  <a href="#" aria-label="Next page"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg></a>
</nav>

CSS

@property --hfx-nav-pagination-ring-sweep {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.hfx-nav-pagination-ring {
  --c: var(--hfx-color, #3b82f6);
  display: flex;
  align-items: center;
  font: 600 var(--hfx-size, 16px)/1.2 system-ui, sans-serif;
  gap: 0.35em;}
.hfx-nav-pagination-ring a {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.4em;
  height: 2.4em;
  border-radius: 50%;
  color: inherit;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  transition: color 0.25s ease;
}
.hfx-nav-pagination-ring a::before {
  --hfx-nav-pagination-ring-sweep: 0deg;
  content: "";
  position: absolute;
  inset: 0;
  border: 0.12em solid var(--c);
  border-radius: 50%;
  -webkit-mask: conic-gradient(#000 var(--hfx-nav-pagination-ring-sweep), transparent 0);
  mask: conic-gradient(#000 var(--hfx-nav-pagination-ring-sweep), transparent 0);
  transition: --hfx-nav-pagination-ring-sweep 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}
.hfx-nav-pagination-ring a[aria-current="page"] {
  background: var(--c);
  color: #fff;
}
.hfx-nav-pagination-ring svg {
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hfx-nav-pagination-ring a:is(:hover, :focus-visible) { color: var(--c); }
.hfx-nav-pagination-ring a[aria-current="page"]:is(:hover, :focus-visible) { color: #fff; }
.hfx-nav-pagination-ring a:is(:hover, :focus-visible)::before { --hfx-nav-pagination-ring-sweep: 360deg; }
.hfx-nav-pagination-ring a:first-child:is(:hover, :focus-visible) svg { transform: translateX(-0.15em); }
.hfx-nav-pagination-ring a:last-child:is(:hover, :focus-visible) svg { transform: translateX(0.15em); }

@media (prefers-reduced-motion: reduce) {
  .hfx-nav-pagination-ring, .hfx-nav-pagination-ring *, .hfx-nav-pagination-ring::before, .hfx-nav-pagination-ring::after, .hfx-nav-pagination-ring *::before, .hfx-nav-pagination-ring *::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

Sliding Pill Nav Hover Effect
Directional Underline Nav Hover Effect
Dot Indicator Nav Hover Effect
Vertical Nav Indicator Hover Effect