webdevpuneet.com

Circular Text Spin — Rotating SVG textPath Badge in CSS

Circular Text Spin · Text Animation · Plain HTML, CSS & JS · Live preview

Copy & paste

Source Code

<main class="stage">
  <a class="badge" href="#contact" aria-label="Available for work, let's talk">
    <svg class="ring" viewBox="0 0 200 200" aria-hidden="true">
      <defs><path id="circle" d="M100,100 m-76,0 a76,76 0 1,1 152,0 a76,76 0 1,1 -152,0"/></defs>
      <text><textPath href="#circle" textLength="474" lengthAdjust="spacing">Available for work • Let's talk • Open to projects • </textPath></text>
    </svg>
    <span class="core" aria-hidden="true">
      <svg width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M7 17 17 7"/><path d="M8 7h9v9"/></svg>
    </span>
  </a>

  <a class="badge small" href="#about" aria-label="Scroll to learn more">
    <svg class="ring rev" viewBox="0 0 200 200" aria-hidden="true">
      <text><textPath href="#circle" textLength="474" lengthAdjust="spacing">Scroll down • Scroll down • Scroll down • </textPath></text>
    </svg>
    <span class="core" aria-hidden="true">
      <svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14"/><path d="m6 13 6 6 6-6"/></svg>
    </span>
  </a>
</main>

Extend with AI

Take This Snippet Further With AI

Ask an AI coding assistant to explain how the two arc commands draw a full circle as a path, why textLength with lengthAdjust="spacing" is used instead of adjusting font size, and where the circumference value in the script comes from. A good follow-up is how to offset the starting position with startOffset.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a rotating circular text badge in plain HTML, CSS and a little JavaScript, with SVG textPath and no libraries.

Requirements:
- A round link element that contains an SVG ring and a centred circular "core" with an arrow icon. The ring is a viewBox of 200 by 200 with a defs path drawing a circle of radius 76 using two arc commands, and a text element with a textPath pointing to it.
- Use textLength and lengthAdjust="spacing" so the phrase fills the circle evenly, and set textLength in JavaScript from 2 * PI * radius so changing the radius keeps it closed.
- The ring rotates 360 degrees with a 16-second linear infinite CSS animation. Make a second, smaller outlined badge whose ring spins in reverse at a different speed.
- On hover, speed the ring up, scale the badge slightly, and rotate the centre arrow 45 degrees.
- Give each badge an aria-label and hide the SVG from assistive technology, because the repeated text is not useful read aloud.
- Disable rotation under prefers-reduced-motion and pause the animation when the document is hidden.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

What's included

Features

Real text on a path
Glyphs follow an SVG circle, so the phrase is selectable, translatable and sharp at any size.
Self-fitting spacing
textLength is set from the circle's circumference so the phrase always closes the ring evenly.
Counter-rotating pair
One badge spins forward, the other in reverse at a different speed, which looks mechanical and balanced.
Hover feedback
The ring speeds up, the badge scales slightly, and the centre arrow turns 45°.
Labelled links
Each badge has an aria-label, and the decorative SVG is hidden from screen readers.
Motion-safe
Rotation is removed for reduced-motion users and paused while the page tab is hidden.

About this UI Snippet

Circular Text Spin — SVG textPath on a Circle With a Rotating Ring

Screenshot of the Circular Text Spin snippet rendered live

That little round badge with words running around the edge has become a portfolio and agency cliché for a reason: it makes a plain link look designed, and it takes almost no space. Here it's built properly with an SVG textPath, so the words are real text that bends along a circle, not an image, and the whole ring turns with a single CSS animation.

How text follows a circle

A circle is defined as a <path> using two arc commands (a76,76 0 1,1 152,0 then back), starting at the left edge. The <textPath href="#circle"> places each glyph along that path. textLength stretches the letter spacing so the phrase fills the circumference exactly, and lengthAdjust="spacing" makes sure it widens the gaps rather than squashing the letters. The script recomputes the length as 2πr so if you change the radius, the text still closes the circle.

Spin is one line of CSS

The ring is an SVG with a rotate(360deg) keyframe, 16s linear and infinite. The second badge runs the same animation in reverse at 12s, which makes the pair feel like gears. On hover the ring's duration drops to 6s and the core arrow rotates 45°, which gives the link a clear "yes, I'm clickable" signal.

Accessible by design

A rotating ring of words is poor for screen readers (they'd read a repeated phrase), so each badge is a link with its own aria-label, and the SVG is hidden from assistive tech. Rotation stops under prefers-reduced-motion, and pauses while the tab is hidden so it doesn't burn cycles in the background.

Step by step

How to Use

  1. 1
    Paste the HTML, CSS and JSTwo round badges appear on a warm background: a black one with an orange arrow core and a smaller outlined one with a down arrow, each with text rotating around it.
  2. 2
    Write your phraseEdit the text inside <textPath>. Keep a separator such as • at the end so the last word doesn't run straight into the first, and aim for 35–55 characters at the default size.
  3. 3
    Change the sizeResize .badge and keep the SVG viewBox. If you change the circle's radius (76), update the path's arc values and the CIRC constant in the JS together.
  4. 4
    Retarget the linkSet the href and aria-label on each badge to the contact section, a booking page or a scroll anchor.
  5. 5
    Swap the centre iconReplace the SVG inside .core with a logo, an initial or an emoji. Keep it under about 45% of the badge width.

Real-world uses

Common Use Cases

Portfolio "available for work" badge
Pin it to a hero corner and link it to a contact section or a booking form.
Scroll cue under a hero
The smaller reverse-spinning "scroll down" badge replaces the usual bouncing arrow.
Agency and studio sites
Use as a "view case study" or "start a project" call to action next to a large heading.
Stamps and seals
Words like "Handmade • Since 2012 • Small batch" around a logo work as a product-page trust mark.
Event passes and ticket pages
A rotating "Limited seats • Book now" ring adds motion to a flat ticket card.

Got questions?

Frequently Asked Questions

The phrase length and the circumference don't match. The script sets textLength to the circumference, but very long text gets squeezed. Shorten the phrase or increase the circle's radius.

The path starts at the left and runs clockwise. To start at the top, rotate the SVG by 90° in the keyframe's starting angle, or use startOffset on the textPath as a percentage.

Yes in all current browsers. Use href (the older xlink:href is only needed for very old Safari). Fonts must be available as web fonts or system fonts since SVG text uses CSS font rules.

A single transform animation on a compositor layer is cheap. Keep the number of spinning badges small and avoid animating the text itself, only the SVG wrapper.