AI CSS Animations

Rotating Circle Text Button

A round call to action with its label set around the rim. On hover the ring of text starts turning, the center disc grows and the arrow swings to point forward. The text follows an SVG textPath.

Also known as: circular text button, spinning text badge, text on a circle css.

HTML

<button class="btn-circle-text-spin" aria-label="Get in touch">
  <svg class="btn-circle-text-spin-ring" viewBox="0 0 100 100" aria-hidden="true">
    <path id="btn-circle-text-spin-path" d="M50 50m-38 0a38 38 0 1 1 76 0a38 38 0 1 1-76 0" fill="none"/>
    <text font-size="10.5" font-weight="700" letter-spacing="1.5"><textPath href="#btn-circle-text-spin-path" textLength="236">GET IN TOUCH &#8226; GET IN TOUCH &#8226;&#160;</textPath></text>
  </svg>
  <svg class="btn-circle-text-spin-arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7M8 7h9v9"/></svg>
</button>

CSS

.btn-circle-text-spin {
  --c: var(--btn-color, #3b82f6);
  font-size: var(--btn-size, 18px);
  display: grid;
  place-items: center;
  width: 7em;
  height: 7em;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 10%, transparent);
  color: var(--c);
  font-family: system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
.btn-circle-text-spin > svg { grid-area: 1 / 1; }
.btn-circle-text-spin-ring {
  width: 100%;
  height: 100%;
  fill: currentColor;
}
.btn-circle-text-spin-arrow {
  width: 2.6em;
  height: 2.6em;
  padding: 0.65em;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-circle-text-spin:is(:hover, :focus-visible) { background-color: color-mix(in srgb, var(--c) 16%, transparent); }
.btn-circle-text-spin:is(:hover, :focus-visible) .btn-circle-text-spin-ring {
  animation: btn-circle-text-spin-turn 8s linear infinite;
}
.btn-circle-text-spin:is(:hover, :focus-visible) .btn-circle-text-spin-arrow { transform: scale(1.15) rotate(45deg); }
@keyframes btn-circle-text-spin-turn {
  to { transform: rotate(360deg); }
}

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

Customizing this snippet

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