Previous and Next buttons that nudge the way they point on hover, with the chevron moving a little further than the button. Hover.css Forward and Backward, paired the way you would use them.
Also known as: hvr-forward, hvr-backward, pagination button hover.
<nav class="hfx-forward-backward" aria-label="Pagination"> <a class="hfx-forward-backward-prev" href="#"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 18l-6-6 6-6"/></svg>Previous</a> <a class="hfx-forward-backward-next" href="#">Next<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 18l6-6-6-6"/></svg></a> </nav>
.hfx-forward-backward {
--c: var(--hfx-color, #3b82f6);
display: inline-flex;
gap: 0.75em;
font: 600 var(--hfx-size, 16px) system-ui, sans-serif;
}
.hfx-forward-backward a {
display: inline-flex;
align-items: center;
gap: 0.35em;
padding: 0.65em 1.15em;
border-radius: 0.5em;
text-decoration: none;
transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.3s ease;
}
.hfx-forward-backward svg {
width: 1.1em;
height: 1.1em;
transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.hfx-forward-backward-prev {
background: color-mix(in srgb, var(--c) 12%, transparent);
color: var(--c);
}
.hfx-forward-backward-next {
background: var(--c);
color: #fff;
}
.hfx-forward-backward-prev:is(:hover, :focus-visible) {
background: color-mix(in srgb, var(--c) 20%, transparent);
transform: translateX(-0.45em);
}
.hfx-forward-backward-prev:is(:hover, :focus-visible) svg {
transform: translateX(-0.2em);
}
.hfx-forward-backward-next:is(:hover, :focus-visible) {
transform: translateX(0.45em);
}
.hfx-forward-backward-next:is(:hover, :focus-visible) svg {
transform: translateX(0.2em);
}
@media (prefers-reduced-motion: reduce) {
.hfx-forward-backward, .hfx-forward-backward *, .hfx-forward-backward::before, .hfx-forward-backward::after, .hfx-forward-backward *::before, .hfx-forward-backward *::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.