DHxWhy

Sliding Puzzle Image Gallery

Galleries 47

About

Sliding puzzle image gallery for React and Tailwind CSS (shadcn/ui): each photo arrives shuffled into a 15-puzzle and solves itself one sliding tile at a time, then the last piece drops in, the seams close and a sheen sweeps across the finished picture. It is built to hold attention: an unfinished picture keeps the eye on it until the last tile clicks into place, and every new photo shows up as scrambled pieces first, so visitors stay to see what it becomes. Visitors can take over: click a tile in line with the gap or use the arrow keys, and the board solves itself again once they stop. Thumbnails, prev and next, a move counter, 3x3 to 6x6 grids, optional tile numbers, details beside the board on wide screens and folded into a compact bar under it on narrow ones, and a reduced-motion fallback. Use it where one image should hold attention: hero sections, product reveals and portfolio highlights.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Sliding Puzzle Image Gallery to your project and fits it to your theme.

Code

How Sliding Puzzle Image Gallery is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { SlidingPuzzleGallery } from "@/components/ui/sliding-puzzle-gallery";
import type { PuzzleItem } from "@/components/ui/sliding-puzzle-gallery";

const settings = {
  size: 4,
  autoplay: true,
  hold: 2400,
  moveDuration: 150,
  shuffleMoves: 16,
  playable: true,
  numbers: false,
  gap: 4,
};

const PHOTOS = [
  { id: "photo-1579264688258-c0ebf8c7942a", title: "Eurasian eagle-owl", caption: "Ear tufts up, orange eyes locked on the lens." },
  { id: "photo-1639104738898-ec92e9e40a0a", title: "Red fox", caption: "Caught mid-step at the edge of the woods." },
  { id: "photo-1619475762212-da12e5e15f18", title: "Tiger in the snow", caption: "Frost on the whiskers and a steady stare." },
  { id: "photo-1542880941-1abfea46bba6", title: "Red panda", caption: "Round ears, white brows and plenty of curiosity." },
  { id: "photo-1544923408-75c5cef46f14", title: "Scarlet macaw", caption: "Red, yellow and blue, all on one bird." },
  { id: "photo-1745933115134-9cd90e3efcc7", title: "Lion", caption: "A heavy golden mane and a calm, slow look." },
];

const ITEMS: PuzzleItem[] = PHOTOS.map(({ id, title, caption }) => ({
  src: `https://images.unsplash.com/${id}?w=1000&h=1000&fit=crop&q=80&auto=format`,
  alt: title,
  title,
  caption,
}));

const CCGATHER_URL = "https://ccgather.com/?utm_source=21st&utm_medium=component&utm_campaign=sliding_puzzle_gallery";

export default function Demo(props: Partial<typeof settings>) {
  const s = { ...settings, ...props };
  return (
    <div className="flex min-h-screen w-full flex-col items-center justify-center gap-5 bg-background p-6 text-foreground">
      <SlidingPuzzleGallery
        items={ITEMS}
        size={s.size}
        autoplay={s.autoplay}
        hold={s.hold}
        moveDuration={s.moveDuration}
        shuffleMoves={s.shuffleMoves}
        playable={s.playable}
        numbers={s.numbers}
        gap={s.gap}
        className="max-w-3xl"
      />
      <p className="text-xs text-muted-foreground">
        Wildlife portraits that solve themselves. Click a tile to take over.{" "}
        <a href={CCGATHER_URL} target="_blank" rel="noreferrer" className="underline underline-offset-4 transition-colors hover:text-foreground">
          By the CCgather team
        </a>
      </p>
    </div>
  );
}

More by DHxWhy

View all
  • Product Rail Gallery – Fashion Store Hero Section

    Product Rail Gallery – Fashion Store Hero Section

    4.1K
  • Sushi Conveyor Belt Menu – Restaurant Hero Section

    Sushi Conveyor Belt Menu – Restaurant Hero Section

    1.8K
  • Team Lanyard Rail – Meet the Team Section with Flip Badges

    Team Lanyard Rail – Meet the Team Section with Flip Badges

    1.8K
  • Skateboard Deck Rail Gallery – Skate Shop Hero Section

    Skateboard Deck Rail Gallery – Skate Shop Hero Section

    968
  • Picture Rail Image Gallery – Art Print Shop Hero Section

    Picture Rail Image Gallery – Art Print Shop Hero Section

    782
  • World Testimonials Globe – Social Proof Hero Section

    World Testimonials Globe – Social Proof Hero Section

    659
  • Sun Moon Dark Mode Theme Toggle

    Sun Moon Dark Mode Theme Toggle

    493
  • Pendant Lamp Rail Gallery – Lighting Store Hero Section

    Pendant Lamp Rail Gallery – Lighting Store Hero Section

    435

More in Galleries

View all
  • Gallery Component

    Gallery Component

    49
  • Photo Deck

    Photo Deck

    82
  • Scattered About

    Scattered About

    83
  • Product Hover Showcase

    Product Hover Showcase

    123
  • Morph Gallery

    Morph Gallery

    5
  • About 3

    About 3

    460
  • File Upload

    File Upload

    22
  • Editorial Collage Hero

    Editorial Collage Hero

    530