AI CSS Animations

Arrow Link Card Hover

A whole-card link whose corner arrow flies out to the top right while a fresh one slides in from the bottom left, and the circle behind it fills. Two copies of one SVG do the swap.

Also known as: card with arrow hover, clickable card arrow animation, arrow swap on hover.

HTML

<a class="hfx-card-arrow-corner" href="#">
  <span class="hfx-card-arrow-corner-arrow" aria-hidden="true">
    <svg viewBox="0 0 24 24"><path d="M7 17 17 7M9 7h8v8"/></svg>
    <svg viewBox="0 0 24 24"><path d="M7 17 17 7M9 7h8v8"/></svg>
  </span>
  <span class="hfx-card-arrow-corner-eyebrow">Docs</span>
  <h3>Read the documentation</h3>
  <p>Guides, API reference and runnable examples.</p>
</a>

CSS

.hfx-card-arrow-corner {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  position: relative;
  display: block;
  box-sizing: border-box;
  width: 15em;
  padding: 1.1em 1.2em 1.2em;
  border: 1px solid color-mix(in srgb, #000 10%, transparent);
  border-radius: 0.8em;
  background: #fff;
  color: #1f2937;
  font-family: system-ui, sans-serif;
  text-decoration: none;
  transition: border-color 0.3s ease, box-shadow 0.35s ease;
}
.hfx-card-arrow-corner:is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--c) 45%, transparent);
  box-shadow: 0 0.8em 1.4em -0.9em color-mix(in srgb, var(--c) 55%, transparent);
}
.hfx-card-arrow-corner-arrow {
  position: absolute;
  top: 0.9em;
  right: 0.9em;
  width: 2.1em;
  height: 2.1em;
  overflow: hidden;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 12%, transparent);
  color: var(--c);
  transition: background-color 0.3s ease, color 0.3s ease;
}
.hfx-card-arrow-corner:is(:hover, :focus-visible) .hfx-card-arrow-corner-arrow {
  background: var(--c);
  color: #fff;
}
.hfx-card-arrow-corner-arrow svg {
  position: absolute;
  inset: 0;
  width: 1.05em;
  height: 1.05em;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.45s cubic-bezier(0.7, 0, 0.2, 1);
}
.hfx-card-arrow-corner-arrow svg:nth-child(2) { transform: translate(-1.6em, 1.6em); }
.hfx-card-arrow-corner:is(:hover, :focus-visible) .hfx-card-arrow-corner-arrow svg:nth-child(1) { transform: translate(1.6em, -1.6em); }
.hfx-card-arrow-corner:is(:hover, :focus-visible) .hfx-card-arrow-corner-arrow svg:nth-child(2) { transform: none; }
.hfx-card-arrow-corner-eyebrow {
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c);
}
.hfx-card-arrow-corner h3 {
  margin: 1.1em 0 0.3em;
  font-size: 1em;
  font-weight: 600;
}
.hfx-card-arrow-corner p {
  margin: 0;
  font-size: 0.8em;
  line-height: 1.45;
  color: #6b7280;
}

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