Orbit Gallery Free React component
Photos ride a tilted ring that spins on its own. Images at the front grow and sharpen, images at the back shrink, blur and fade, and a drag flings the whole ring with momentum. A portfolio hero nobody scrolls past.
Get the code
npx shadcn@latest add https://alphenex.com/r/orbit-gallery.jsonWorks with any React project through the shadcn CLI. Prefer to paste it yourself? Copy the two files below into components/alphenex/. No Tailwind or animation library needed.
import OrbitGallery from '@/components/alphenex/orbit-gallery';
<OrbitGallery images={[{ src: '/work-1.jpg', alt: 'Project one' }, /* ... */]} />'use client';
import { useEffect, useRef } from 'react';
import './orbit-gallery.css';
/**
* OrbitGallery
* Images ride a tilted ring that spins on its own. Photos at the front grow
* and sharpen, photos at the back shrink and fade. Drag to fling it.
*
* Free from Alphenex Lab: https://alphenex.com/lab/orbit-gallery (MIT)
*/
export default function OrbitGallery({
images = [], // [{ src, alt }]
radius = 220, // ring radius in px
size = 96, // image size in px at the front of the ring
speed = 14, // spin in degrees per second
tilt = 0.32, // 0 = flat line, 1 = full circle
className = '',
style,
...props
}) {
const ringRef = useRef(null);
useEffect(() => {
const ring = ringRef.current;
if (!ring) return undefined;
const items = [...ring.children];
const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
let angle = 0;
let velocity = 0; // extra spin from dragging, degrees per frame
let dragging = false;
let lastX = 0;
let last = performance.now();
let frame = 0;
const place = () => {
const step = 360 / items.length;
items.forEach((item, i) => {
const a = ((angle + i * step) * Math.PI) / 180;
const depth = (Math.sin(a) + 1) / 2; // 0 back, 1 front
const x = Math.cos(a) * radius;
const y = Math.sin(a) * radius * tilt;
const scale = 0.45 + depth * 0.55;
item.style.transform = `translate(-50%, -50%) translate3d(${x}px, ${y}px, 0) scale(${scale})`;
item.style.zIndex = String(Math.round(depth * 100));
item.style.opacity = String(0.35 + depth * 0.65);
item.style.filter = depth < 0.5 ? `blur(${(0.5 - depth) * 4}px)` : '';
});
};
const loop = (now) => {
const dt = Math.min(0.05, (now - last) / 1000);
last = now;
if (!dragging) {
velocity *= 0.95;
angle += (reduce ? 0 : speed * dt) + velocity;
}
place();
frame = requestAnimationFrame(loop);
};
const down = (e) => {
dragging = true;
lastX = e.clientX;
velocity = 0;
ring.setPointerCapture?.(e.pointerId);
};
const move = (e) => {
if (!dragging) return;
const dx = e.clientX - lastX;
lastX = e.clientX;
angle += dx * 0.35;
velocity = dx * 0.35;
};
const up = () => {
dragging = false;
};
place();
frame = requestAnimationFrame(loop);
ring.addEventListener('pointerdown', down);
window.addEventListener('pointermove', move, { passive: true });
window.addEventListener('pointerup', up);
return () => {
cancelAnimationFrame(frame);
ring.removeEventListener('pointerdown', down);
window.removeEventListener('pointermove', move);
window.removeEventListener('pointerup', up);
};
}, [images.length, radius, speed, tilt]);
return (
<div
className={`alx-orbit ${className}`}
style={{ '--alx-orbit-size': `${size}px`, height: radius * tilt * 2 + size * 1.6, ...style }}
{...props}
>
<div ref={ringRef} className="alx-orbit__ring" role="list" aria-label="Image gallery">
{images.map((image, i) => (
<figure key={image.src + i} className="alx-orbit__item" role="listitem">
<img src={image.src} alt={image.alt || ''} draggable="false" loading="lazy" decoding="async" />
</figure>
))}
</div>
</div>
);
}
/* OrbitGallery, Alphenex Lab (MIT) */
.alx-orbit {
position: relative;
width: 100%;
touch-action: pan-y;
user-select: none;
}
.alx-orbit__ring {
position: absolute;
inset: 0;
cursor: grab;
}
.alx-orbit__ring:active {
cursor: grabbing;
}
.alx-orbit__item {
position: absolute;
left: 50%;
top: 50%;
width: var(--alx-orbit-size, 96px);
aspect-ratio: 4 / 5;
margin: 0;
overflow: hidden;
border-radius: 14px;
box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.55);
will-change: transform, opacity;
}
.alx-orbit__item img {
width: 100%;
height: 100%;
object-fit: cover;
pointer-events: none;
}
Paste this into Claude, ChatGPT, Cursor, Lovable or v0 to build it from scratch.
Build a React "OrbitGallery" component with plain CSS. Place N images on an ellipse (x = cos(a) × radius, y = sin(a) × radius × tilt) and spin the angle with requestAnimationFrame. Use the depth (sin(a) mapped to 0–1) to scale each image from 0.45 to 1, fade it from 0.35 to 1 opacity, blur the back half and set z-index so front images overlap back ones. Dragging horizontally rotates the ring and leaves momentum that decays by 5% a frame. Props: images [{ src, alt }], radius, size, speed (degrees per second), tilt. Respect prefers-reduced-motion by stopping the auto-spin.How the orbit gallery works
Every image sits on an ellipse. Its angle gives an x from the cosine and a y from the sine, squashed by the tilt so the circle reads as a ring seen from slightly above.
The same sine gives a depth value from 0 at the back to 1 at the front. Depth drives the scale, the opacity, a light blur and the stacking order, which is enough to fake real 3D without WebGL or CSS 3D transforms.
One animation loop adds a slow spin plus any momentum from dragging. Releasing a drag keeps the last speed and lets it decay, so the ring coasts to its normal pace.
Frequently asked questions
Want motion like this on your website?
We design and build custom websites with motion, 3D and SEO built in. Websites from $500.