Orbiting Circles
Orbiting icons for React and Tailwind CSS: any children travel around a shared centre on a circular path, spaced evenly and always upright. Stack several rings with different radii, speeds and directions for integration showcases, tech-stack heroes and team clouds.
- Multiple rings
- Icons stay upright
- Pause on hover & focus
- Pauses off-screen
- prefers-reduced-motion
import { Cloud, Code2, Cpu, Database, GitBranch, Globe, Lock, Moon, Terminal, Zap } from "lucide-react";
import { OrbitingCircles } from "@/components/dusk/orbiting-circles/orbiting-circles";
const chip =
"flex size-full items-center justify-center rounded-full border border-white/10 bg-card text-muted-foreground";
export default function OrbitingCirclesDemo() {
return (
<div className="relative flex h-[420px] w-full items-center justify-center overflow-hidden">
<div className="relative z-10 flex size-16 items-center justify-center rounded-xl border bg-card text-foreground">
<Moon className="size-7" aria-hidden />
<span className="sr-only">DuskUI</span>
</div>
<OrbitingCircles radius={80} duration={16} iconSize={36}>
<span className={chip}><Zap className="size-4" aria-hidden /></span>
<span className={chip}><Lock className="size-4" aria-hidden /></span>
<span className={chip}><Cpu className="size-4" aria-hidden /></span>
<span className={chip}><Terminal className="size-4" aria-hidden /></span>
</OrbitingCircles>
<OrbitingCircles radius={160} duration={28} reverse iconSize={44}>
<span className={chip}><Globe className="size-5" aria-hidden /></span>
<span className={chip}><Database className="size-5" aria-hidden /></span>
<span className={chip}><GitBranch className="size-5" aria-hidden /></span>
<span className={chip}><Cloud className="size-5" aria-hidden /></span>
<span className={chip}><Code2 className="size-5" aria-hidden /></span>
</OrbitingCircles>
</div>
);
}Installation
$ npx shadcn@latest add https://duskui.com/r/orbiting-circles.json1. Install the dependencies.
npm install motion2. Copy the source into
components/dusk/orbiting-circles/orbiting-circles.tsx.orbiting-circles.tsx "use client"; import * as React from "react"; import { animate, motion, useMotionValue, useReducedMotion, useTransform, type AnimationPlaybackControls, type MotionValue, } from "motion/react"; import { cn } from "@/lib/utils"; export interface OrbitingCirclesProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> { /** The items to orbit. They are spaced evenly around the ring. */ children: React.ReactNode; /** Radius of the orbit in px. */ radius?: number; /** Seconds for one full lap. */ duration?: number; /** Orbit counter-clockwise. */ reverse?: boolean; /** Where the first item sits, in degrees (0 = right, 90 = bottom). */ startAngle?: number; /** Draw the orbit ring. */ path?: boolean; /** Width and height of each item's slot in px. */ iconSize?: number; /** Stop the ring while the pointer is over an item or an item has keyboard focus. */ pauseOnHover?: boolean; /** Classes for the orbit ring. */ pathClassName?: string; /** Classes for each item's slot. */ itemClassName?: string; } function OrbitItem({ rotation, angle, radius, size, className, children, }: { rotation: MotionValue<number>; angle: number; radius: number; size: number; className?: string; children: React.ReactNode; }) { // Translating (instead of rotating the whole ring) keeps every item upright. const x = useTransform(rotation, (r) => Math.round(radius * Math.cos(((r + angle) * Math.PI) / 180) * 100) / 100); const y = useTransform(rotation, (r) => Math.round(radius * Math.sin(((r + angle) * Math.PI) / 180) * 100) / 100); return ( <motion.div data-slot="orbiting-circles-item" className={cn( "pointer-events-auto absolute left-1/2 top-1/2 flex items-center justify-center", className )} style={{ x, y, width: size, height: size, marginLeft: -size / 2, marginTop: -size / 2 }} > {children} </motion.div> ); } /** * Items travelling around a shared centre on a circular orbit. Stack several * `OrbitingCircles` in one positioned container for multiple rings; each one * fills that container and centres itself. * * One motion value drives every item, so React never re-renders while it * spins. It pauses off-screen and in hidden tabs, optionally on hover and * focus, and under reduced motion the items rest, evenly spaced. */ export function OrbitingCircles({ children, radius = 120, duration = 20, reverse = false, startAngle = -90, path = true, iconSize = 40, pauseOnHover = false, pathClassName, itemClassName, className, onPointerEnter, onPointerLeave, onFocus, onBlur, ...props }: OrbitingCirclesProps) { const reduceMotion = useReducedMotion(); const rootRef = React.useRef<HTMLDivElement>(null); const rotation = useMotionValue(0); const controls = React.useRef<AnimationPlaybackControls | null>(null); const state = React.useRef({ onScreen: true, hovered: false, focused: false }); const items = React.Children.toArray(children); const step = items.length ? 360 / items.length : 0; const sync = React.useCallback(() => { const c = controls.current; if (!c) return; const s = state.current; const paused = !s.onScreen || document.hidden || (pauseOnHover && (s.hovered || s.focused)); if (paused) c.pause(); else c.play(); }, [pauseOnHover]); React.useEffect(() => { const root = rootRef.current; if (!root || reduceMotion) { rotation.set(0); return; } const from = rotation.get() % 360; const c = animate(rotation, [from, from + (reverse ? -360 : 360)], { duration: Math.max(0.1, duration), ease: "linear", repeat: Infinity, }); controls.current = c; sync(); const observer = new IntersectionObserver(([entry]) => { state.current.onScreen = entry.isIntersecting; sync(); }); observer.observe(root); document.addEventListener("visibilitychange", sync); return () => { c.stop(); controls.current = null; observer.disconnect(); document.removeEventListener("visibilitychange", sync); }; }, [rotation, duration, reverse, reduceMotion, sync]); return ( <div ref={rootRef} data-slot="orbiting-circles" className={cn("pointer-events-none absolute inset-0 flex items-center justify-center", className)} onPointerEnter={(e) => { onPointerEnter?.(e); state.current.hovered = true; sync(); }} onPointerLeave={(e) => { onPointerLeave?.(e); state.current.hovered = false; sync(); }} onFocus={(e) => { onFocus?.(e); state.current.focused = true; sync(); }} onBlur={(e) => { onBlur?.(e); if (!e.currentTarget.contains(e.relatedTarget as Node | null)) { state.current.focused = false; sync(); } }} {...props} > {path && ( <div aria-hidden className={cn("absolute rounded-full border border-white/10", pathClassName)} style={{ width: radius * 2, height: radius * 2 }} /> )} <div className="relative size-0"> {items.map((child, i) => ( <OrbitItem key={React.isValidElement(child) && child.key != null ? child.key : i} rotation={rotation} angle={startAngle + step * i} radius={radius} size={iconSize} className={itemClassName} > {child} </OrbitItem> ))} </div> </div> ); }
Usage
import { Cloud, Database, Globe } from "lucide-react"
import { OrbitingCircles } from "@/components/dusk/orbiting-circles/orbiting-circles"
export function Stack() {
return (
<div className="relative flex h-96 items-center justify-center">
<span className="relative z-10 text-xl font-semibold">Dusk</span>
<OrbitingCircles radius={90}>
<Globe />
<Database />
<Cloud />
</OrbitingCircles>
<OrbitingCircles radius={150} duration={30} reverse>
{/* … */}
</OrbitingCircles>
</div>
)
}Examples
Pause on hover
With pauseOnHover the ring stops while the pointer is over an item or an item has keyboard focus, so the buttons are easy to hit. Style the ring with pathClassName.
Design team
6 members
import { OrbitingCircles } from "@/components/dusk/orbiting-circles/orbiting-circles";
const people = [
{ initials: "AK", name: "Ana K." },
{ initials: "JS", name: "Jon S." },
{ initials: "MR", name: "Mia R." },
{ initials: "TO", name: "Tom O." },
{ initials: "LV", name: "Lea V." },
{ initials: "DN", name: "Dev N." },
];
export default function OrbitingCirclesHover() {
return (
<div className="relative flex h-80 w-full items-center justify-center overflow-hidden">
<div className="relative z-10 text-center">
<p className="text-sm font-medium text-foreground">Design team</p>
<p className="text-xs text-muted-foreground">6 members</p>
</div>
<OrbitingCircles radius={115} duration={24} iconSize={44} pauseOnHover pathClassName="border-dashed">
{people.map((p) => (
<button
key={p.initials}
type="button"
aria-label={`${p.name}'s profile`}
className="flex size-full items-center justify-center rounded-full border bg-muted text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50"
>
{p.initials}
</button>
))}
</OrbitingCircles>
</div>
);
}Speeds & start angles
One item per ring with its own radius, duration, iconSize and startAngle. Purely decorative rings can take aria-hidden.
import { OrbitingCircles } from "@/components/dusk/orbiting-circles/orbiting-circles";
const planet = "size-full rounded-full";
export default function OrbitingCirclesSolar() {
return (
<div className="relative flex h-96 w-full items-center justify-center overflow-hidden">
<div aria-hidden className="relative z-10 size-12 rounded-full bg-amber-300" />
<OrbitingCircles radius={50} duration={6} iconSize={10} startAngle={20} aria-hidden>
<span className={`${planet} bg-stone-300`} />
</OrbitingCircles>
<OrbitingCircles radius={85} duration={11} iconSize={16} startAngle={200} aria-hidden>
<span className={`${planet} bg-sky-400`} />
</OrbitingCircles>
<OrbitingCircles radius={125} duration={19} iconSize={14} startAngle={110} aria-hidden>
<span className={`${planet} bg-orange-400`} />
</OrbitingCircles>
<OrbitingCircles radius={170} duration={34} iconSize={26} startAngle={300} pathClassName="border-dashed" aria-hidden>
<span className={`${planet} bg-amber-200`} />
</OrbitingCircles>
</div>
);
}API Reference
Each OrbitingCircles fills its nearest positioned parent and centres itself; put the centre content in that parent with relative z-10. Also accepts any div attribute.
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Items to orbit, spaced evenly around the ring. |
| radius | number | 120 | Orbit radius in px. |
| duration | number | 20 | Seconds per lap. |
| reverse | boolean | false | Orbit counter-clockwise. |
| startAngle | number | -90 | Angle of the first item in degrees (0 = right, -90 = top). |
| path | boolean | true | Draw the orbit ring. |
| iconSize | number | 40 | Width and height of each item slot in px. |
| pauseOnHover | boolean | false | Stop while an item is hovered or focused. |
| pathClassName | string | — | Classes for the orbit ring. |
| itemClassName | string | — | Classes for each item slot. |
Accessibility
- Items are rendered once, in source order, so screen readers and the Tab key meet them in a predictable sequence regardless of where they are on the ring.
- pauseOnHover also pauses on keyboard focus, so a focused link never moves away from its focus ring.
- The ring is aria-hidden. Give icon-only items an accessible name, or mark a purely decorative orbit aria-hidden.
- One motion value drives every item, so React never re-renders while it spins, and the animation pauses off-screen and in hidden tabs.
- With prefers-reduced-motion the items rest, evenly spaced, at their start angles.