AI CSS Animations

Rotating Dashed Circle Text

A dashed ring and a dotted inner ring turn slowly in opposite directions around a short word, like a sale badge or a stamp. Plain dashed and dotted borders on round elements, rotated.

Also known as: dashed circle around text, spinning border badge css, rotating circle highlight.

NEW

HTML

<div class="txt-rotating-dashed-circle-text"><span class="txt-rotating-dashed-circle-text-ring" aria-hidden="true"></span><span class="txt-rotating-dashed-circle-text-ring" aria-hidden="true"></span><span>NEW</span></div>

CSS

.txt-rotating-dashed-circle-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;
  display: inline-grid;
  place-items: center;
  color: var(--c);
  font-weight: 800;
  letter-spacing: 0.08em;}
.txt-rotating-dashed-circle-text > span {
  grid-area: 1 / 1;
}
.txt-rotating-dashed-circle-text-ring {
  width: 3.4em;
  height: 3.4em;
  border: 0.08em dashed var(--c);
  border-radius: 50%;
  animation: txt-rotating-dashed-circle-text-spin 12s linear infinite;
}
.txt-rotating-dashed-circle-text-ring + .txt-rotating-dashed-circle-text-ring {
  width: 2.8em;
  height: 2.8em;
  border: 0.08em dotted color-mix(in srgb, var(--c) 55%, transparent);
  animation-duration: 16s;
  animation-direction: reverse;
}
@keyframes txt-rotating-dashed-circle-text-spin {
  to { transform: rotate(360deg); }
}

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

Tailwind CSS version

The same effect using Tailwind utility classes. No custom CSS or config needed.

<div class="inline-grid place-items-center text-xl font-extrabold tracking-widest text-blue-500">
  <span aria-hidden="true" class="col-start-1 row-start-1 h-24 w-24 animate-spin rounded-full border-2 border-dashed border-blue-500 [animation-duration:12s]"></span>
  <span aria-hidden="true" class="col-start-1 row-start-1 h-20 w-20 animate-spin rounded-full border-2 border-dotted border-blue-500/60 [animation-direction:reverse] [animation-duration:16s]"></span>
  <span class="col-start-1 row-start-1">NEW</span>
</div>

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