Reorder Grid
Reorder Grid: Drag-and-drop sortable grid driven by Motion's native Reorder primitives with spring elevation and haptic feedback. Free MIT React & Next.js source with Motion and Tailwind CSS, live preview, CLI install and docs.
Install Reorder Grid
npx motion-ui-skill add reorder-gridComponents install as source into your project. The interactive page also includes preview, code, documentation and install tabs.
Dependencies
clsxlucide-reactmotionreacttailwind-merge
Source files
Reorder Grid
Drag-and-drop sortable grid driven by Motion's native Reorder primitives with spring elevation and haptic feedback. Inspired by Motion (Framer Motion) and KeenThemes ReUI.
Install
npx motion-ui-skill add reorder-grid
Dependencies
clsxlucide-reactmotionreacttailwind-merge
Usage
"use client";
import { ReorderGrid, type ReorderItem } from "@/components/motion/reorder-grid";
import { Folder, FileText, Image, Code } from "lucide-react";
import { useState } from "react";
const INITIAL_ITEMS: ReorderItem[] = [
{ id: "1", title: "Documents", subtitle: "14 files", icon: <Folder className="size-4" />, badge: "Active" },
{ id: "2", title: "Images", subtitle: "84 assets", icon: <Image className="size-4" /> },
{ id: "3", title: "Source Code", subtitle: "Git repository", icon: <Code className="size-4" />, badge: "Main" },
{ id: "4", title: "Invoices", subtitle: "Q3 reports", icon: <FileText className="size-4" /> },
];
export function ReorderGridExample() {
const [items, setItems] = useState(INITIAL_ITEMS);
return (
<div className="max-w-xl p-8">
<ReorderGrid
items={items}
columns={2}
onChange={(newOrder) => setItems(newOrder)}
/>
</div>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items |
ReorderItem[] |
Required | Array of draggable grid items. |
onChange |
(items: ReorderItem[]) => void |
undefined |
Callback fired when items are reordered. |
columns |
1 | 2 | 3 | 4 |
2 |
Number of responsive grid columns. |
className |
string |
undefined |
Container classes. |