Components / Layout
Shuffle Grid
A grid whose tiles smoothly glide to new spots as it reshuffles. Pauses on hover.
1
2
3
4
5
6
7
8
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/shuffle-grid.tsx. - 3
Use it
example.tsximport { ShuffleGrid } from "@/components/ui/shuffle-grid"; const tiles = [ "from-orange-400 to-rose-500", "from-sky-400 to-indigo-500", "from-lime-400 to-emerald-500", "from-fuchsia-400 to-purple-600", "from-amber-300 to-orange-500", "from-teal-300 to-cyan-600", "from-rose-400 to-pink-600", "from-violet-400 to-indigo-600", ]; export default function ShuffleGridDemo() { return ( <ShuffleGrid className="w-full max-w-sm" items={tiles.map((g, i) => ({ id: g, content: ( <div className={`flex aspect-square items-end rounded-xl bg-gradient-to-br ${g} p-2 text-xs font-semibold text-white`}> {i + 1} </div> ), }))} /> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | { id; content: ReactNode }[] | — | Tiles. |
| interval | number | 2500 | Milliseconds between shuffles (0 = off). |
| columns | number | 4 | Number of columns. |