AI CSS Animations

Diagonal Wipe Text Reveal

A slanted edge sweeps across the line while the text inside drifts the other way, so the reveal has depth. A clip-path polygon on the wrapper and a small translate on the text.

Also known as: diagonal text reveal css, clip path polygon reveal, slanted wipe text.

New season

HTML

<div class="txt-diagonal-wipe-reveal"><span class="txt-diagonal-wipe-reveal-t">New season</span></div>

CSS

.txt-diagonal-wipe-reveal {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  display: inline-block;
  padding: 0 0.2em;
  white-space: nowrap;
  color: var(--c);
  /* the edge runs from the bottom point up to a top point 30% further right */
  clip-path: polygon(0 0, 0 0, -30% 100%, 0 100%);
  animation: txt-diagonal-wipe-reveal-wipe 1.1s cubic-bezier(0.45, 0, 0.2, 1) forwards;}
.txt-diagonal-wipe-reveal-t {
  display: inline-block;
  animation: txt-diagonal-wipe-reveal-drift 1.3s cubic-bezier(0.3, 0, 0.2, 1) both;
}
@keyframes txt-diagonal-wipe-reveal-wipe {
  to { clip-path: polygon(0 0, 130% 0, 100% 100%, 0 100%); }
}
@keyframes txt-diagonal-wipe-reveal-drift {
  from { transform: translateX(0.6em); }
  to   { transform: translateX(0); }
}

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

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • 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 text animations