Icon Cloud
A 3D icon cloud for React: icons or logos spread evenly over a rotating sphere, with the nearest ones larger and brighter. Hover to steer it, drag to fling it, and pass any React node or image URL. Ideal for tech stacks, integrations and partner walls.
- 3D sphere
- React nodes or images
- Hover to steer
- Drag with momentum
- Screen-reader list
- Pauses off-screen
- React
- TypeScript
- Tailwind CSS
- Motion
- Postgres
- Node.js
- Edge functions
- Git
- GitHub
- CLI
- npm
- Docker
- Design system
- Auth
- Security
- Deploys
- Caching
- Analytics
- Workers
- Webhooks
- JSON APIs
- MDX
- CDN
- AI
import {
Atom,
Boxes,
Braces,
Cloud,
CodeXml,
Cpu,
Database,
FileCode,
Gauge,
GitBranch,
Github,
Globe,
Layers,
Lock,
Package,
Palette,
Rocket,
Server,
Shield,
Sparkles,
Terminal,
WandSparkles,
Webhook,
Zap,
} from "lucide-react";
import { IconCloud, type IconCloudItem } from "@/components/dusk/icon-cloud/icon-cloud";
const icons = [
[Atom, "React"],
[CodeXml, "TypeScript"],
[Palette, "Tailwind CSS"],
[WandSparkles, "Motion"],
[Database, "Postgres"],
[Server, "Node.js"],
[Cloud, "Edge functions"],
[GitBranch, "Git"],
[Github, "GitHub"],
[Terminal, "CLI"],
[Package, "npm"],
[Boxes, "Docker"],
[Layers, "Design system"],
[Lock, "Auth"],
[Shield, "Security"],
[Rocket, "Deploys"],
[Zap, "Caching"],
[Gauge, "Analytics"],
[Cpu, "Workers"],
[Webhook, "Webhooks"],
[Braces, "JSON APIs"],
[FileCode, "MDX"],
[Globe, "CDN"],
[Sparkles, "AI"],
] as const;
const items: IconCloudItem[] = icons.map(([Icon, label]) => ({ label, icon: <Icon /> }));
export default function IconCloudDemo() {
return (
<div className="flex w-full items-center justify-center overflow-hidden rounded-xl border border-white/10 bg-background p-6">
<IconCloud
items={items}
label="Our stack"
itemClassName="rounded-xl border border-white/10 bg-card text-foreground/80 shadow-sm"
/>
</div>
);
}Installation
$ npx shadcn@latest add https://duskui.com/r/icon-cloud.json1. Install the dependencies.
npm install motion2. Copy the source into
components/dusk/icon-cloud/icon-cloud.tsx.icon-cloud.tsx "use client"; import * as React from "react"; import { useReducedMotion } from "motion/react"; import { cn } from "@/lib/utils"; export type IconCloudItem = { /** Accessible name, also shown as a tooltip. */ label: string; /** Turns the icon into a link. */ href?: string; } & ({ icon: React.ReactNode; src?: never } | { src: string; icon?: never }); export interface IconCloudProps extends Omit<React.ComponentProps<"div">, "children"> { /** The icons: a React node (`icon`) or an image URL (`src`), each with a `label`. */ items: IconCloudItem[]; /** Width and height of each icon slot in px. */ iconSize?: number; /** Idle spin in radians per second. */ speed?: number; /** Steer the spin toward the cursor while hovering (mouse only). */ steerOnHover?: boolean; /** Let people spin the sphere by dragging, with momentum on release. */ draggable?: boolean; /** Scale of the icons nearest to the viewer. Far icons shrink to about half of it. */ maxScale?: number; /** Accessible name of the list. */ label?: string; /** Classes for each icon slot. */ itemClassName?: string; } type Vec3 = [number, number, number]; /** Row-major 3×3 rotation matrix. */ type Mat3 = [number, number, number, number, number, number, number, number, number]; /** Evenly spread points on a unit sphere (golden-angle spiral), so the layout is the same on every render. */ function fibonacciSphere(count: number): Vec3[] { const golden = Math.PI * (3 - Math.sqrt(5)); return Array.from({ length: count }, (_, i) => { const y = 1 - ((i + 0.5) / count) * 2; const r = Math.sqrt(1 - y * y); const a = i * golden; return [Math.cos(a) * r, y, Math.sin(a) * r]; }); } /** Rotation around screen X by `ax`, then screen Y by `ay`, applied on top of `m`. */ function rotate(m: Mat3, ax: number, ay: number): Mat3 { const cx = Math.cos(ax); const sx = Math.sin(ax); const cy = Math.cos(ay); const sy = Math.sin(ay); // R = Ry(ay) · Rx(ax) const r: Mat3 = [cy, sy * sx, sy * cx, 0, cx, -sx, -sy, cy * sx, cy * cx]; const out = new Array(9) as Mat3; for (let row = 0; row < 3; row++) { for (let col = 0; col < 3; col++) { out[row * 3 + col] = r[row * 3] * m[col] + r[row * 3 + 1] * m[3 + col] + r[row * 3 + 2] * m[6 + col]; } } return out; } /** Re-orthonormalizes the matrix so floating-point drift never skews the sphere. */ function orthonormalize(m: Mat3): Mat3 { const a: Vec3 = [m[0], m[1], m[2]]; const la = Math.hypot(...a) || 1; const x: Vec3 = [a[0] / la, a[1] / la, a[2] / la]; const b: Vec3 = [m[3], m[4], m[5]]; const d = b[0] * x[0] + b[1] * x[1] + b[2] * x[2]; const by: Vec3 = [b[0] - d * x[0], b[1] - d * x[1], b[2] - d * x[2]]; const lb = Math.hypot(...by) || 1; const y: Vec3 = [by[0] / lb, by[1] / lb, by[2] / lb]; const z: Vec3 = [x[1] * y[2] - x[2] * y[1], x[2] * y[0] - x[0] * y[2], x[0] * y[1] - x[1] * y[0]]; return [...x, ...y, ...z]; } /** A fixed starting tilt so the sphere reads as 3D before it moves. */ const INITIAL: Mat3 = rotate([1, 0, 0, 0, 1, 0, 0, 0, 1], -0.35, 0.4); const round = (n: number) => Math.round(n * 1000) / 1000; /** Projected style for one point: position as a fraction of the radius, plus depth-driven scale and opacity. */ function project(m: Mat3, p: Vec3, maxScale: number) { const x = m[0] * p[0] + m[1] * p[1] + m[2] * p[2]; const y = m[3] * p[0] + m[4] * p[1] + m[5] * p[2]; const z = m[6] * p[0] + m[7] * p[1] + m[8] * p[2]; // depth: 0 at the back, 1 nearest the viewer. const depth = (z + 1) / 2; return { x: round(x), y: round(y), scale: round(maxScale * (0.5 + 0.5 * depth)), opacity: round(0.22 + 0.78 * depth * depth), z: Math.round(depth * 100), }; } /** A slowly rotating 3D sphere of icons that you can steer by hovering or spin by dragging, with nearer icons larger and brighter. */ export function IconCloud({ items, iconSize = 40, speed = 0.35, steerOnHover = true, draggable = true, maxScale = 1.1, label = "Icons", itemClassName, className, style, ...props }: IconCloudProps) { const reduceMotion = useReducedMotion() ?? false; const rootRef = React.useRef<HTMLDivElement>(null); const itemRefs = React.useRef<(HTMLLIElement | null)[]>([]); const points = React.useMemo(() => fibonacciSphere(items.length), [items.length]); React.useEffect(() => { const root = rootRef.current; if (!root) return; let matrix = INITIAL; let frames = 0; const idle = { x: -speed * 0.25, y: speed }; // Angular velocity in rad/s around the screen X and Y axes. const velocity = { ...idle }; const target = { ...idle }; const pointer = { hovering: false, dragging: false, lastX: 0, lastY: 0, lastT: 0 }; let focused = false; let onScreen = false; let raf = 0; let last = 0; const paint = () => { for (let i = 0; i < points.length; i++) { const el = itemRefs.current[i]; if (!el) continue; const p = project(matrix, points[i], maxScale); el.style.setProperty("--x", String(p.x)); el.style.setProperty("--y", String(p.y)); el.style.setProperty("--s", String(p.scale)); el.style.opacity = String(p.opacity); el.style.zIndex = String(p.z); } }; const turn = (ax: number, ay: number) => { matrix = rotate(matrix, ax, ay); if (++frames % 60 === 0) matrix = orthonormalize(matrix); }; const animating = () => !reduceMotion && onScreen && !document.hidden; const frame = (now: number) => { raf = 0; const dt = last ? Math.min((now - last) / 1000, 0.1) : 0; last = now; if (!pointer.dragging) { // Ease toward the target spin: hover steering, idle drift, or the tail of a fling. const k = 1 - Math.exp(-dt * (pointer.hovering ? 4 : 1.2)); const goal = focused ? { x: 0, y: 0 } : target; velocity.x += (goal.x - velocity.x) * k; velocity.y += (goal.y - velocity.y) * k; turn(velocity.x * dt, velocity.y * dt); } paint(); if (animating()) raf = requestAnimationFrame(frame); }; const start = () => { if (!raf && animating()) { last = 0; raf = requestAnimationFrame(frame); } }; const stop = () => { cancelAnimationFrame(raf); raf = 0; }; const radius = () => Math.max(1, root.clientWidth / 2 - iconSize / 2); const onPointerMove = (e: PointerEvent) => { if (pointer.dragging) { const dx = e.clientX - pointer.lastX; const dy = e.clientY - pointer.lastY; const now = e.timeStamp; const dt = Math.max(0.001, (now - pointer.lastT) / 1000); const r = radius(); turn(-dy / r, dx / r); // Track the drag speed so the release keeps spinning. velocity.x = velocity.x * 0.5 + (-dy / r / dt) * 0.5; velocity.y = velocity.y * 0.5 + (dx / r / dt) * 0.5; pointer.lastX = e.clientX; pointer.lastY = e.clientY; pointer.lastT = now; if (!raf) paint(); return; } if (!steerOnHover || reduceMotion || e.pointerType !== "mouse") return; const rect = root.getBoundingClientRect(); const nx = ((e.clientX - rect.left) / rect.width) * 2 - 1; const ny = ((e.clientY - rect.top) / rect.height) * 2 - 1; pointer.hovering = true; // Icons drift toward the cursor's side; the further out, the faster. target.x = -ny * speed * 4; target.y = nx * speed * 4; }; const onPointerLeave = () => { pointer.hovering = false; target.x = idle.x; target.y = idle.y; }; const onPointerDown = (e: PointerEvent) => { if (!draggable || (e.pointerType === "mouse" && e.button !== 0)) return; if ((e.target as HTMLElement).closest("a")) return; pointer.dragging = true; pointer.lastX = e.clientX; pointer.lastY = e.clientY; pointer.lastT = e.timeStamp; velocity.x = 0; velocity.y = 0; root.setPointerCapture(e.pointerId); }; const onPointerUp = (e: PointerEvent) => { if (!pointer.dragging) return; pointer.dragging = false; if (root.hasPointerCapture(e.pointerId)) root.releasePointerCapture(e.pointerId); // Ignore a stale velocity if the pointer rested before letting go. if (e.timeStamp - pointer.lastT > 80) { velocity.x = 0; velocity.y = 0; } const cap = 8; velocity.x = Math.max(-cap, Math.min(cap, velocity.x)); velocity.y = Math.max(-cap, Math.min(cap, velocity.y)); if (e.pointerType !== "mouse") onPointerLeave(); }; const onFocusIn = () => { focused = true; }; const onFocusOut = (e: FocusEvent) => { if (!root.contains(e.relatedTarget as Node | null)) focused = false; }; const intersection = new IntersectionObserver(([entry]) => { onScreen = entry.isIntersecting; if (onScreen) start(); else stop(); }); intersection.observe(root); const onVisibility = () => (document.hidden ? stop() : start()); document.addEventListener("visibilitychange", onVisibility); root.addEventListener("pointermove", onPointerMove); root.addEventListener("pointerleave", onPointerLeave); root.addEventListener("pointerdown", onPointerDown); root.addEventListener("pointerup", onPointerUp); root.addEventListener("pointercancel", onPointerUp); root.addEventListener("focusin", onFocusIn); root.addEventListener("focusout", onFocusOut); paint(); return () => { stop(); intersection.disconnect(); document.removeEventListener("visibilitychange", onVisibility); root.removeEventListener("pointermove", onPointerMove); root.removeEventListener("pointerleave", onPointerLeave); root.removeEventListener("pointerdown", onPointerDown); root.removeEventListener("pointerup", onPointerUp); root.removeEventListener("pointercancel", onPointerUp); root.removeEventListener("focusin", onFocusIn); root.removeEventListener("focusout", onFocusOut); }; }, [points, speed, steerOnHover, draggable, maxScale, iconSize, reduceMotion]); return ( <div ref={rootRef} data-slot="icon-cloud" className={cn( "relative aspect-square w-full max-w-[400px] select-none [container-type:inline-size]", draggable && "cursor-grab touch-pan-y active:cursor-grabbing", className )} style={ { ...style, // Sphere radius: half the container minus half an icon, so icons never poke out. "--r": `calc(50cqw - ${iconSize / 2}px)`, } as React.CSSProperties } {...props} > <ul aria-label={label} className="absolute inset-0"> {items.map((item, i) => { // The first paint is computed here so server and client agree and nothing jumps on hydration. const p = project(INITIAL, points[i], maxScale); const content = item.src ? ( // eslint-disable-next-line @next/next/no-img-element -- plain <img> keeps the component framework-agnostic. <img src={item.src} alt="" draggable={false} className="size-full object-contain" /> ) : ( item.icon ); const visual = ( <span aria-hidden className="flex size-full items-center justify-center [&_svg]:size-[60%]"> {content} </span> ); return ( <li key={`${item.label}-${i}`} ref={(el) => { itemRefs.current[i] = el; }} data-slot="icon-cloud-item" title={item.label} className={cn("absolute left-1/2 top-1/2 will-change-transform", itemClassName)} style={ { width: iconSize, height: iconSize, marginLeft: -iconSize / 2, marginTop: -iconSize / 2, "--x": p.x, "--y": p.y, "--s": p.scale, opacity: p.opacity, zIndex: p.z, transform: "translate3d(calc(var(--x) * var(--r)), calc(var(--y) * var(--r)), 0) scale(var(--s))", } as React.CSSProperties } > {item.href ? ( <a href={item.href} className="block size-full rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-ring/60" draggable={false} > {visual} <span className="sr-only">{item.label}</span> </a> ) : ( <> {visual} <span className="sr-only">{item.label}</span> </> )} </li> ); })} </ul> </div> ); }
The cloud is square and fills its parent up to max-w-[400px]. Icons are laid out on a Fibonacci sphere, so the same items always land in the same places, on the server and in the browser.
Usage
import { Database, Github, Server } from "lucide-react"
import { IconCloud } from "@/components/dusk/icon-cloud/icon-cloud"
export function Stack() {
return (
<IconCloud
label="Our stack"
items={[
{ label: "GitHub", icon: <Github /> },
{ label: "Postgres", icon: <Database /> },
{ label: "Node.js", icon: <Server /> },
{ label: "Acme", src: "/logos/acme.svg" },
]}
/>
)
}Examples
Colorful icons, drag only
Style each icon however you like. steerOnHover={false} keeps a steady drift until it's dragged, and a larger maxScale exaggerates the depth.
- Apple
- Bird
- Cat
- Cherry
- Citrus
- Dog
- Fish
- Flower
- Grape
- Leaf
- Rabbit
- Snail
- Squirrel
- Sprout
- Trees
- Turtle
Drag to spin: it keeps its momentum, then settles back to a slow drift.
import { Apple, Bird, Cat, Cherry, Citrus, Dog, Fish, Flower2, Grape, Leaf, Rabbit, Snail, Squirrel, Sprout, Trees, Turtle } from "lucide-react";
import { IconCloud, type IconCloudItem } from "@/components/dusk/icon-cloud/icon-cloud";
const palette = ["#c9a3b1", "#cbbd8f", "#94b8a5", "#97b1c6", "#aaa0c4", "#c7a58e"];
const icons = [
[Apple, "Apple"],
[Bird, "Bird"],
[Cat, "Cat"],
[Cherry, "Cherry"],
[Citrus, "Citrus"],
[Dog, "Dog"],
[Fish, "Fish"],
[Flower2, "Flower"],
[Grape, "Grape"],
[Leaf, "Leaf"],
[Rabbit, "Rabbit"],
[Snail, "Snail"],
[Squirrel, "Squirrel"],
[Sprout, "Sprout"],
[Trees, "Trees"],
[Turtle, "Turtle"],
] as const;
const items: IconCloudItem[] = icons.map(([Icon, label], i) => ({
label,
icon: <Icon style={{ color: palette[i % palette.length] }} strokeWidth={1.75} />,
}));
export default function IconCloudColors() {
return (
<div className="flex w-full flex-col items-center gap-2 rounded-xl border border-white/10 bg-background p-6">
<IconCloud items={items} iconSize={48} speed={0.2} steerOnHover={false} maxScale={1.3} className="max-w-[300px]" label="Nature icons" />
<p className="text-sm text-white/60">Drag to spin: it keeps its momentum, then settles back to a slow drift.</p>
</div>
);
}Links
Give items an href to make them links. While anything inside has keyboard focus the sphere stops, so tabbing through never chases a moving target.
import { Blocks, Bot, Calendar, Camera, Chromium, Figma, Gitlab, Mail, MessageSquare, Music, Slack, Trello, Twitch, Video, Youtube } from "lucide-react";
import { IconCloud, type IconCloudItem } from "@/components/dusk/icon-cloud/icon-cloud";
const icons = [
[Slack, "Slack"],
[Figma, "Figma"],
[Gitlab, "GitLab"],
[Trello, "Trello"],
[Chromium, "Chromium"],
[Youtube, "YouTube"],
[Twitch, "Twitch"],
[Mail, "Email"],
[Calendar, "Calendar"],
[MessageSquare, "Chat"],
[Camera, "Camera"],
[Video, "Video calls"],
[Music, "Music"],
[Bot, "Bots"],
[Blocks, "Plugins"],
] as const;
const items: IconCloudItem[] = icons.map(([Icon, label]) => ({ label, icon: <Icon />, href: "#integrations" }));
export default function IconCloudHero() {
return (
<div className="grid w-full items-center gap-6 rounded-xl border border-white/10 bg-background p-6 sm:grid-cols-[1fr_auto] sm:p-10">
<div>
<h3 className="text-xl font-semibold tracking-tight text-foreground sm:text-2xl">Connects to the tools you already use</h3>
<p className="mt-2 max-w-sm text-sm text-muted-foreground">
Each icon is a link. Tab into the cloud and it stops spinning so you can pick one.
</p>
</div>
<IconCloud
items={items}
iconSize={36}
className="mx-auto max-w-[260px]"
label="Integrations"
itemClassName="text-white/70 transition-colors hover:text-white"
/>
</div>
);
}API Reference
Any other div prop is passed to the root. Rotation runs in a single animation frame loop that writes styles directly, so React never re-renders while it spins.
| Prop | Type | Default | Description |
|---|---|---|---|
| items | IconCloudItem[] | — | { label, icon } or { label, src }, plus an optional href. |
| iconSize | number | 40 | Width and height of each icon slot in px. |
| speed | number | 0.35 | Idle spin in radians per second. |
| steerOnHover | boolean | true | Spin toward the cursor while a mouse hovers. |
| draggable | boolean | true | Spin by dragging, with momentum on release. |
| maxScale | number | 1.1 | Scale of the nearest icons; the farthest are half of it. |
| label | string | "Icons" | Accessible name of the list. |
| itemClassName | string | — | Classes for each icon slot. |
Accessibility
- The icons render as a real
<ul>with each item'slabelas text, so screen readers get a plain list. - Icons with an href are links; focusing one pauses the rotation.
- With prefers-reduced-motion the sphere holds still and hover steering is off; dragging still turns it, without momentum.
- The animation stops while the cloud is off-screen or the tab is hidden.