A narrow glint of light sweeps across the letters every few seconds, like light catching metal.
Text circles slowly around an icon, like a stamp. Pauses under the pointer and picks up where it stopped.
Customize
Usage
import { ArrowUpRight } from "lucide-react";
import { RotatingBadge } from "@/components/motionkit/rotating-badge";
<a href="/contact" aria-label="Available for projects">
<RotatingBadge text="Available for projects">
<ArrowUpRight />
</RotatingBadge>
</a>Motion
The exact curves this component runs, plotted with Motion's own maths.
Turn
Runs on its own
"Scroll down", "Open to work" and "Book a call" stamps in hero corners, beside portfolio projects or on product shots.
The text runs along a circular SVG textPath, repeated as many times as fits and sized with textLength so the copies fill the ring evenly. A frame clock turns it rather than a fixed loop, so it can pause under the pointer and carry on from the same angle.
Works in the App Router as is. Requires Tailwind CSS v4.
One command adds the file and installs its dependencies. Needs a components.json (run npx shadcn@latest init once if you don't have one).
npx shadcn@latest add https://www.motionkitui.com/r/rotating-badge.jsonnpm install motionSave as components/motionkit/rotating-badge.tsx.
"use client";
import { useId, useRef, type ReactNode } from "react";
import { motion, useAnimationFrame, useMotionValue, useReducedMotion } from "motion/react";
type RotatingBadgeProps = {
/** Text around the ring. It repeats to fill the circle. */
text: string;
/** What sits in the middle, e.g. an icon or a logo. */
children?: ReactNode;
/** Diameter in pixels. */
size?: number;
/** Seconds for one full turn. */
duration?: number;
/** Turn the other way. */
reverse?: boolean;
/** Stop turning while the pointer is over the badge. */
pauseOnHover?: boolean;
color?: string;
className?: string;
};
export function RotatingBadge({
text,
children,
size = 120,
duration = 14,
reverse = false,
pauseOnHover = true,
color = "#F6F1E8",
className = "",
}: RotatingBadgeProps) {
const reduceMotion = useReducedMotion();
const pathId = useId();
const rotate = useMotionValue(0);
const hovered = useRef(false);
// turned by a frame clock rather than a fixed loop, so it can pause on hover and resume where it stopped
useAnimationFrame((_, delta) => {
if (reduceMotion || (pauseOnHover && hovered.current)) return;
rotate.set((rotate.get() + ((reverse ? -360 : 360) * delta) / (duration * 1000)) % 360);
});
const radius = 38;
const circumference = 2 * Math.PI * radius;
// repeat the phrase as often as fits at a comfortable size, then scale the type so the copies
// fill the ring; textLength trims the last fraction, so spacing never has to squash
const phrase = `${text.trim()} · `;
const charWidth = 0.68; // average uppercase advance plus tracking, in ems
const repeats = Math.max(1, Math.round(circumference / (phrase.length * charWidth * 7)));
const fontSize = Math.min(10, Math.max(5, circumference / (repeats * phrase.length * charWidth)));
const ring = phrase.repeat(repeats);
return (
<div
className={`relative inline-flex items-center justify-center ${className}`}
style={{ width: size, height: size }}
onPointerEnter={() => (hovered.current = true)}
onPointerLeave={() => (hovered.current = false)}
>
<span className="sr-only">{text}</span>
<motion.svg
aria-hidden
viewBox="0 0 100 100"
className="absolute inset-0 size-full"
style={{ rotate }}
>
<defs>
<path id={pathId} d={`M 50 50 m -${radius} 0 a ${radius} ${radius} 0 1 1 ${radius * 2} 0 a ${radius} ${radius} 0 1 1 -${radius * 2} 0`} />
</defs>
<text fill={color} fontSize={fontSize} fontWeight={500} letterSpacing={fontSize * 0.08} style={{ textTransform: "uppercase" }}>
<textPath href={`#${pathId}`} textLength={circumference} lengthAdjust="spacing">
{ring}
</textPath>
</text>
</motion.svg>
<span className="relative flex items-center justify-center" style={{ color }}>
{children}
</span>
</div>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | — | Text around the ring. It repeats to fill the circle. |
| children | ReactNode | — | What sits in the middle. |
| size | number | 120 | Diameter in pixels. |
| duration | number | 14 | Seconds per turn. |
| reverse | boolean | false | Turn anticlockwise. |
| pauseOnHover | boolean | true | Stop while the pointer is over it. |
| color | string | "#F6F1E8" | Text and icon colour. |
How we audit: the WCAG 2.2 animation checklist and respecting reduced motion in React.
Yes. The file starts with "use client", so you can import it straight into a Server Component page or layout. It works in Vite as is, and in Astro as a React island.
Only the motion package, beside React and Tailwind CSS v4. There is no MotionKit package and no Tailwind config to add.
Yes. Run npx shadcn@latest add https://www.motionkitui.com/r/rotating-badge.json in any project with a components.json. It saves the file to components/motionkit and installs its dependencies.
With reduced motion on, the badge holds still.
A narrow glint of light sweeps across the letters every few seconds, like light catching metal.
Headline text with a slowly flowing, seamlessly looping gradient.
Pools of colour swirl and flow inside the letters, for headings that feel alive without moving an inch.