AI CSS Animations

Clip Path Wipe Button

A slanted wipe where the label changes color exactly under the edge, letter by letter. A filled copy of the button is revealed with clip-path, so the text never vanishes into the fill.

Also known as: text color wipe button, two tone text hover, clip-path reveal button.

HTML

<button class="hfx-clip-path-wipe">Download<span class="hfx-clip-path-wipe-fill" aria-hidden="true">Download</span></button>

CSS

.hfx-clip-path-wipe {
  --c: var(--hfx-color, #3b82f6);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.75em;
  border-radius: 0.5em;
  font: 600 var(--hfx-size, 16px)/1.2 system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid var(--c);
  background: transparent;
  color: var(--c);
}
.hfx-clip-path-wipe-fill {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--c);
  color: #fff;
  clip-path: polygon(0 0, 0 0, -30% 100%, 0 100%);
  transition: clip-path 0.55s cubic-bezier(0.65, 0, 0.35, 1);
}
.hfx-clip-path-wipe:is(:hover, :focus-visible) {
  background-color: var(--c); /* hides the hairline where the fill meets the border */
  transition: background-color 0s 0.55s;
}
.hfx-clip-path-wipe:is(:hover, :focus-visible) .hfx-clip-path-wipe-fill {
  clip-path: polygon(0 0, 135% 0, 105% 100%, 0 100%);
}

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