Radial Carousel Free React component
A gallery that opens into a ring of thumbnails orbiting the active photo. Spin it by dragging, tap any thumbnail to bring it to the centre.
Original component by Watermelon UI · MIT licence
Get the code
npx shadcn@latest add https://registry.watermelon.sh/r/radial-carousel.jsonInstalls from the Watermelon UI registry through the shadcn CLI. Needs Tailwind CSS and the motion package, which the command adds for you.
import { RadialCarousel } from '../radial-carousel';
const demo_images = [
{ id: 1, url: 'https://images.unsplash.com/photo-1501785888041-af3ef285b470?auto=format&fit=crop&w=800&q=80', title: 'Mountain Lake' },
{ id: 2, url: 'https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=800&q=80', title: 'Yosemite' },
{ id: 3, url: 'https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?auto=format&fit=crop&w=800&q=80', title: 'Misty Forest' },
{ id: 4, url: 'https://images.unsplash.com/photo-1441974231531-c6227db76b6e?auto=format&fit=crop&w=800&q=80', title: 'Sunlight Forest' },
{ id: 5, url: 'https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=800&q=80', title: 'Grasslands' },
{ id: 6, url: 'https://images.unsplash.com/photo-1472396961693-142e6e269027?auto=format&fit=crop&w=800&q=80', title: 'Deer in Field' },
{ id: 7, url: 'https://images.unsplash.com/photo-1467830839049-11173e7b2755?q=80&w=1332&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', title: 'Autumn Road' },
{ id: 8, url: 'https://images.unsplash.com/photo-1469474968028-56623f02e42e?auto=format&fit=crop&w=800&q=80', title: 'Hills' },
{ id: 9, url: 'https://images.unsplash.com/photo-1447752875215-b2761acb3c5d?auto=format&fit=crop&w=800&q=80', title: 'Morning mist' },
{ id: 10, url: 'https://images.unsplash.com/photo-1546882588-d9bd63f85a7e?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTV8fHdhdGVyJTIwZmFsbHxlbnwwfHwwfHx8MA%3D%3D', title: 'Waterfall' },
{ id: 11, url: 'https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?auto=format&fit=crop&w=800&q=80', title: 'Snowy Peak' },
{ id: 12, url: 'https://images.unsplash.com/photo-1414235077428-338989a2e8c0?auto=format&fit=crop&w=800&q=80', title: 'Culinary' },
];
export default function RadialCarouselDemo() {
return (
<div className="sm:h-[650px] h-[500px] w-full flex flex-col items-center justify-center">
<RadialCarousel
items={demo_images}
radius={250}
thumbnailSize={110}
centerSize={350}
/>
</div>
);
};
// radial-carousel, from Watermelon UI: https://ui.watermelon.sh/animated-components/radial-carousel
// MIT License. Copyright (c) 2025-present Watermelon Contributors.
'use client';
import React, { useState, useCallback, useEffect } from 'react';
import {
motion,
AnimatePresence,
type Variants,
useMotionValue,
useSpring,
useTransform,
type MotionValue,
} from 'motion/react';
import { X } from 'lucide-react';
export interface GalleryItem {
id: string | number;
url: string;
title?: string;
}
export interface RadialCarouselProps {
items: GalleryItem[];
radius?: number;
thumbnailSize?: number;
centerSize?: number;
}
export const RadialCarousel: React.FC<RadialCarouselProps> = ({
items,
radius = 260,
thumbnailSize = 110,
centerSize = 400,
}) => {
const [isExpanded, setIsExpanded] = useState(false);
const [activeIndex, setActiveIndex] = useState(0);
const [isPanning, setIsPanning] = useState(false);
const [responsiveSizes, setResponsiveSizes] = useState({
radius,
thumbnailSize,
centerSize,
});
useEffect(() => {
const updateSizes = () => {
const width = window.innerWidth;
if (width < 400) {
setResponsiveSizes({
radius: Math.min(radius, 110),
thumbnailSize: Math.min(thumbnailSize, 70),
centerSize: Math.min(centerSize, 260),
});
} else if (width < 640) {
setResponsiveSizes({
radius: Math.min(radius, 140),
thumbnailSize: Math.min(thumbnailSize, 80),
centerSize: Math.min(centerSize, 300),
});
} else if (width < 1024) {
setResponsiveSizes({
radius: Math.min(radius, 200),
thumbnailSize: Math.min(thumbnailSize, 90),
centerSize: Math.min(centerSize, 340),
});
} else {
setResponsiveSizes({ radius, thumbnailSize, centerSize });
}
};
updateSizes();
window.addEventListener('resize', updateSizes);
return () => window.removeEventListener('resize', updateSizes);
}, [radius, thumbnailSize, centerSize]);
const rotation = useMotionValue(0);
const smoothRotation = useSpring(rotation, {
bounce: 0.15,
duration: 0.1,
});
const toggleExpand = useCallback(() => {
setIsExpanded((prev) => !prev);
}, []);
const handleItemClick = (index: number) => {
setActiveIndex(index);
setIsExpanded(false);
};
const containerVariants: Variants = {
collapsed: { transition: { staggerChildren: 0.01, staggerDirection: -1 } },
expanded: { transition: { staggerChildren: 0.03, delayChildren: 0.1 } },
};
return (
<div className="relative flex h-[350px] w-full touch-pan-y items-center justify-center overflow-visible select-none sm:h-[450px]">
<AnimatePresence mode="popLayout">
{!isExpanded ? (
<motion.div
key="center-view"
layout
transition={{ type: 'spring', bounce: 0.15, duration: 0.15 }}
className="relative z-10"
>
<motion.div
layoutId={`card-${items[activeIndex].id}`}
style={{
width: responsiveSizes.centerSize,
height: responsiveSizes.centerSize,
}}
className="relative overflow-hidden rounded-[32px] border border-neutral-200 bg-white p-3 shadow-2xl transition-colors duration-300 sm:rounded-[42px] sm:p-4 dark:border-neutral-800 dark:bg-neutral-900"
>
<motion.img
layoutId={`img-${items[activeIndex].id}`}
src={items[activeIndex].url}
alt={items[activeIndex].title}
className="h-full w-full rounded-[28px] object-cover sm:rounded-[36px]"
draggable={false}
/>
<button
onClick={toggleExpand}
className="absolute top-6 right-6 flex h-8 w-8 items-center justify-center rounded-full bg-neutral-100 shadow-xl backdrop-blur-xl transition-all duration-200 hover:scale-105 hover:bg-white active:scale-95 sm:top-8 sm:right-8 sm:h-10 sm:w-10 dark:bg-white/10 dark:hover:bg-white/20"
>
<X
size={20}
className="text-neutral-500 sm:hidden dark:text-white"
/>
<X
size={28}
className="hidden text-neutral-500 sm:block dark:text-white"
/>
</button>
</motion.div>
</motion.div>
) : (
<motion.div
key="radial-view"
variants={containerVariants}
initial="collapsed"
animate="expanded"
exit="collapsed"
className={`relative flex h-full w-full cursor-grab items-center justify-center active:cursor-grabbing ${
isPanning ? 'touch-none' : 'touch-pan-y'
}`}
onPanStart={() => setIsPanning(true)}
onPanEnd={() => setIsPanning(false)}
onPan={(_, info) => {
rotation.set(rotation.get() + info.delta.x * 0.5);
}}
>
{items.map((item, index) => {
const baseAngle =
(index / items.length) * (2 * Math.PI) - Math.PI / 2;
return (
<Item
key={item.id}
item={item}
baseAngle={baseAngle}
radius={responsiveSizes.radius}
thumbnailSize={responsiveSizes.thumbnailSize}
rotation={smoothRotation}
onClick={() => handleItemClick(index)}
/>
);
})}
</motion.div>
)}
</AnimatePresence>
</div>
);
};
interface ItemProps {
item: GalleryItem;
baseAngle: number;
radius: number;
thumbnailSize: number;
rotation: MotionValue<number>;
onClick: () => void;
}
const Item: React.FC<ItemProps> = ({
item,
baseAngle,
radius,
thumbnailSize,
rotation,
onClick,
}) => {
const x = useTransform(rotation, (r: number) => {
const currentAngle = baseAngle + (r * Math.PI) / 180;
return Math.cos(currentAngle) * radius;
});
const y = useTransform(rotation, (r: number) => {
const currentAngle = baseAngle + (r * Math.PI) / 180;
return Math.sin(currentAngle) * radius;
});
const rotate = useTransform(rotation, (r: number) => {
const currentAngle = baseAngle + (r * Math.PI) / 180;
return (currentAngle * 180) / Math.PI + 90;
});
const itemVariants: Variants = {
collapsed: {
opacity: 0,
scale: 0.8,
transition: { type: 'spring', bounce: 0.4, duration: 0.5 },
},
expanded: {
scale: 1,
opacity: 1,
transition: { type: 'spring', bounce: 0.4, duration: 0.5 },
},
};
return (
<motion.div
variants={itemVariants}
style={{ x, y, rotate }}
onClick={onClick}
className="absolute cursor-pointer"
>
<motion.div
layoutId={`card-${item.id}`}
style={{ width: thumbnailSize, height: thumbnailSize }}
className="overflow-hidden rounded-[18px] border border-neutral-200 bg-white p-1 shadow-2xl ring-1 ring-black/5 transition-colors duration-300 sm:rounded-[24px] dark:border-neutral-800 dark:bg-neutral-900 dark:ring-white/5"
>
<motion.img
layoutId={`img-${item.id}`}
src={item.url}
alt={item.title}
className="h-full w-full rounded-[13px] object-cover sm:rounded-[18px]"
draggable={false}
/>
</motion.div>
</motion.div>
);
};
Paste this into Claude, ChatGPT, Cursor, Lovable or v0 to build it from scratch.
Build a React component called "Radial Carousel" with Tailwind CSS and Motion (motion/react). A gallery that opens into a ring of thumbnails orbiting the active photo. Spin it by dragging, tap any thumbnail to bring it to the centre. Use spring transitions, keep it accessible with keyboard focus and aria labels, respect prefers-reduced-motion, and make it work on touch screens. Export it as a single .tsx file with sensible default props so it renders a complete demo on its own.How the radial carousel works
A gallery that opens into a ring of thumbnails orbiting the active photo. Spin it by dragging, tap any thumbnail to bring it to the centre. The component is a single TypeScript file built with React, Tailwind CSS and Motion, so the animation runs on springs and shared layouts instead of hand-written keyframes.
It comes from Watermelon UI, an open-source component library released under the MIT licence. Install it with the shadcn command above, or copy the source from the code tab into your project.
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.