AI CSS Animations

Hand-Drawn Emphasis Lines

Three quick pen flicks burst from the corner of a word and it hops, the doodled 'look here' marks from landing pages. Three short SVG paths drawn one after another with pathLength="1".

Also known as: doodle emphasis marks, attention lines animation, sparkle lines around text.

Brand new

HTML

<div class="txt-emphasis-lines-text">Brand <span class="txt-emphasis-lines-text-word">new<svg viewBox="0 0 40 40" aria-hidden="true"><path pathLength="1" d="M7 28 L5 9" /><path pathLength="1" d="M14 31 L29 16" /><path pathLength="1" d="M17 38 L36 36" /></svg></span></div>

CSS

.txt-emphasis-lines-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;
  white-space: nowrap;}
.txt-emphasis-lines-text-word {
  position: relative;
  display: inline-block;
  margin-right: 0.5em;
  color: var(--c);
  transform-origin: 30% 90%;
  animation: txt-emphasis-lines-text-hop 0.4s ease-out 0.3s;
}
.txt-emphasis-lines-text-word svg {
  position: absolute;
  left: 96%;
  bottom: 62%;
  width: 0.85em;
  height: 0.85em;
  overflow: visible;
  fill: none;
  stroke: var(--c);
  stroke-width: 4.2;
  stroke-linecap: round;
}
.txt-emphasis-lines-text-word path {
  stroke-dasharray: 1 1.1;
  stroke-dashoffset: 1.05;
  animation: txt-emphasis-lines-text-flick 0.18s ease-out forwards;
}
.txt-emphasis-lines-text-word path:nth-child(1) { animation-delay: 0.35s; }
.txt-emphasis-lines-text-word path:nth-child(2) { animation-delay: 0.47s; }
.txt-emphasis-lines-text-word path:nth-child(3) { animation-delay: 0.59s; }
@keyframes txt-emphasis-lines-text-flick {
  to { stroke-dashoffset: 0; }
}
@keyframes txt-emphasis-lines-text-hop {
  40% { transform: translateY(-0.12em) rotate(-4deg) scale(1.08); }
}

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