AI CSS Animations

Skew Fill Button

A slanted panel wipes across the button on hover. The pseudo-element is skewed and oversized so its angled edge crosses the whole width cleanly.

Also known as: diagonal fill button, angled wipe hover.

HTML

<button class="hfx-skew-fill">View pricing</button>

CSS

.hfx-skew-fill {
  --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;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 2px solid var(--c);
  background: transparent;
  color: var(--c);
  transition: color 0.35s ease;}
.hfx-skew-fill::before {
  content: "";
  position: absolute;
  inset: 0 -20%;
  z-index: -1;
  background: var(--c);
  transform: skewX(-20deg) translateX(-120%);
  transition: transform 0.35s ease;
}
.hfx-skew-fill:hover { color: #fff; }
.hfx-skew-fill:hover::before { transform: skewX(-20deg) translateX(0); }

@media (prefers-reduced-motion: reduce) {
  .hfx-skew-fill, .hfx-skew-fill *, .hfx-skew-fill::before, .hfx-skew-fill::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