AI CSS Animations

Candy Stripe Text

Diagonal stripes in your accent and a pale tint roll through heavy letters like a barber pole. The stripes are one small tile, the same trick as striped progress bars, moved by one tile.

Also known as: striped text css, barber pole text, candy cane text.

Candy Shop

HTML

<div class="txt-candy-stripe-text">Candy Shop</div>

CSS

.txt-candy-stripe-text {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 0.02em;
  background: linear-gradient(45deg,
    var(--c) 25%, color-mix(in srgb, var(--c) 30%, #fff) 25% 50%, var(--c) 50% 75%, color-mix(in srgb, var(--c) 30%, #fff) 75%) 0 0 / 0.5em 0.5em;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0.045em 0 color-mix(in srgb, var(--c) 70%, #000));
  animation: txt-candy-stripe-text-roll 1.2s linear infinite;}
@keyframes txt-candy-stripe-text-roll {
  to { background-position: 0.5em 0; }
}

@media (prefers-reduced-motion: reduce) {
  .txt-candy-stripe-text, .txt-candy-stripe-text *, .txt-candy-stripe-text::before, .txt-candy-stripe-text::after, .txt-candy-stripe-text *::before, .txt-candy-stripe-text *::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