A card with a soft glow that tracks the pointer across its surface.
A little pile of instant photos that fans out like a hand of cards on hover, each print lifting clear as you point at it.
Customize
Usage
import { PhotoFan } from "@/components/motionkit/photo-fan";
<PhotoFan
photos={[
{ src: "/trip/1.jpg", alt: "Sunrise over the hills", caption: "first light" },
{ src: "/trip/2.jpg", alt: "Blue hour in the valley", caption: "blue hour" },
{ src: "/trip/3.jpg", alt: "Dunes at golden hour", caption: "golden" },
]}
/>Motion
The exact curves this component runs, plotted with Motion's own maths.
Fan out
Hover, focus or tap
Print lifts
Point at a print
About pages and personal sites, travel and wedding photography, team culture sections, and testimonials with a photo of each customer.
The prints share one bottom-centre position and are rotated around a point below themselves, so changing the angle swings them out like cards held in a hand. Stacked, each has a small fixed tilt so the pile looks dropped on a table and matches on the server and in the browser. Fanned, the angles are spread evenly across the spread prop and nudged outwards. Pointing at a print raises it above the others with a lift, a slight scale and a gloss. Everything runs on springs, and touch gets a tap to open and a tap to lift.
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/photo-fan.jsonnpm install motionSave as components/motionkit/photo-fan.tsx.
"use client";
import { useState } from "react";
import { motion, useReducedMotion } from "motion/react";
export type FanPhoto = { src: string; alt: string; caption?: string };
type PhotoFanProps = {
photos: FanPhoto[];
/** Total angle in degrees the photos spread across when fanned. */
spread?: number;
/** Width of each print in pixels. */
width?: number;
/** Start fanned out instead of stacked. */
open?: boolean;
className?: string;
};
// small, fixed tilts so the stack looks dropped on a table, the same on the server and in the browser
const resting = [-4, 3, -1.5, 5, -3, 2, -5, 1];
/**
* A little pile of instant photos. Hover or focus and they fan out like a hand of cards; point at one and it lifts
* clear of the others. On touch, a tap opens the fan and a second tap on a print raises it.
*/
export function PhotoFan({ photos, spread = 46, width = 132, open = false, className = "" }: PhotoFanProps) {
const reduceMotion = useReducedMotion();
const [hovered, setHovered] = useState(false);
const [tapped, setTapped] = useState(open);
const [lifted, setLifted] = useState<number | null>(null);
const fanned = hovered || tapped || open;
const count = photos.length;
const middle = (count - 1) / 2;
const height = Math.round(width * 1.22);
const spring = reduceMotion ? { duration: 0 } : { type: "spring" as const, stiffness: 260, damping: 24 };
return (
<div
role="group"
aria-label={`${count} photos`}
onPointerEnter={(event) => event.pointerType === "mouse" && setHovered(true)}
onPointerLeave={() => {
setHovered(false);
setLifted(null);
}}
onFocus={() => setTapped(true)}
onBlur={(event) => {
if (!event.currentTarget.contains(event.relatedTarget)) {
setTapped(open);
setLifted(null);
}
}}
onClick={() => setTapped(true)}
className={`relative flex items-end justify-center ${className}`}
style={{ width: width * (1.6 + count * 0.32), height: height * 1.45 }}
>
{photos.map((photo, index) => {
const offset = index - middle;
const angle = count > 1 ? (offset / middle) * (spread / 2) : 0;
const isLifted = lifted === index;
return (
<motion.figure
key={photo.src + index}
tabIndex={0}
aria-label={photo.caption ?? photo.alt}
onPointerEnter={(event) => event.pointerType === "mouse" && setLifted(index)}
onFocus={() => setLifted(index)}
onClick={(event) => {
if (!fanned) return;
event.stopPropagation();
setLifted(isLifted ? null : index);
}}
className="absolute bottom-4 m-0 cursor-pointer rounded-[3px] bg-[#F6F1E8] p-2 pb-0 shadow-[0_1px_2px_rgb(0_0_0/0.3),0_14px_30px_-8px_rgb(0_0_0/0.55)] outline-none focus-visible:ring-2 focus-visible:ring-[#5FAEB4] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0C1010]"
style={{ width, transformOrigin: "50% 140%", zIndex: isLifted ? count + 1 : index }}
initial={false}
animate={
fanned
? { rotate: angle, x: offset * width * 0.2, y: isLifted ? -26 : Math.abs(offset) * 4, scale: isLifted ? 1.06 : 1 }
: { rotate: resting[index % resting.length], x: offset * 3, y: 0, scale: 1 }
}
transition={spring}
>
{/* eslint-disable-next-line @next/next/no-img-element -- framework-agnostic: works outside Next.js too */}
<img src={photo.src} alt={photo.alt} draggable={false} className="block w-full rounded-[1px] object-cover" style={{ height: height - 40 }} />
<figcaption className="flex h-8 items-center justify-center truncate px-1 font-serif text-[13px] italic text-[#2A2622]">{photo.caption ?? ""}</figcaption>
{/* a gloss that catches the light as a print is raised */}
<motion.span
aria-hidden
className="pointer-events-none absolute inset-0 rounded-[3px] bg-[linear-gradient(135deg,rgb(255_255_255/0.35),transparent_45%)]"
initial={false}
animate={{ opacity: isLifted ? 1 : 0 }}
transition={{ duration: reduceMotion ? 0 : 0.25 }}
/>
</motion.figure>
);
})}
</div>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
| photos | FanPhoto[] | — | Each photo's src, alt and an optional handwritten-style caption. |
| spread | number | 46 | Total angle in degrees the fan opens across. |
| width | number | 132 | Width of each print in pixels. |
| open | boolean | false | Start fanned out instead of stacked. |
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/photo-fan.json in any project with a components.json. It saves the file to components/motionkit and installs its dependencies.
With reduced motion on, the fan opens and prints lift instantly instead of springing.
A card with a soft glow that tracks the pointer across its surface.
Cards that morph smoothly into a full detail view, then fold back into place.
A disc of liquid glass that glides after the cursor, enlarging whatever is beneath it, with a rainbow rim and a highlight rolling across the dome.