AI CSS Animations

Icon Slide Button

The arrow nudges to the right when you hover, which is enough to say 'this goes somewhere'. Works for any inline icon, not just an arrow.

Also known as: arrow button hover, moving arrow.

HTML

<button class="hfx-icon-slide">Continue <span aria-hidden="true">&rarr;</span></button>

CSS

.hfx-icon-slide {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 1.6em;
  border-radius: 0.5em;
  font: 600 1em system-ui, sans-serif;
  cursor: pointer;
  border: 0;
  background: var(--c);
  color: #fff;}
.hfx-icon-slide span {
  display: inline-block;
  transition: transform 0.25s ease;
}
.hfx-icon-slide:hover span { transform: translateX(0.3em); }

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

Tailwind CSS version

The same effect using Tailwind utility classes. No custom CSS or config needed.

<button class="group inline-flex items-center gap-2 rounded-lg bg-blue-500 px-6 py-3 font-semibold text-white">
  Continue <span class="transition-transform duration-200 group-hover:translate-x-1">&rarr;</span>
</button>

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