Basic example
dnd-grid/basic-exampleFreeComponent
Simple draggable and resizable grid.
Install it
npx shadcn@latest add https://dnd-grid.com/r/basic-example.jsonSource
1"use client";23import { DndGrid, type Layout } from "@dnd-grid/react";4import { useState } from "react";56const initialLayout: Layout = [7 { id: "a", x: 0, y: 0, w: 3, h: 2 },8 { id: "b", x: 3, y: 0, w: 3, h: 2 },9 { id: "c", x: 6, y: 0, w: 3, h: 2 },10 { id: "d", x: 9, y: 0, w: 3, h: 2 },11];1213export function BasicExample() {14 const [layout, setLayout] = useState<Layout>(initialLayout);1516 return (17 <DndGrid18 cols={12}19 layout={layout}20 onLayoutChange={setLayout}21 rowHeight={50}22 >23 {layout.map((item) => (24 <div className="grid-item" key={item.id}>25 {item.id}26 </div>27 ))}28 </DndGrid>29 );30}
What it pulls in
npm packages
Files it writes
More from dnd-grid
All 19 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Allow overlapallow-overlap-example | dnd-grid | Components | Free | 3 deps | |
| Aspect ratio constraintsaspect-ratio-constraints-example | dnd-grid | Components | Free | 3 deps | |
| Boundedbounded-example | dnd-grid | Components | Free | 3 deps | |
| Compactor showcasecompactor-showcase-example | dnd-grid | Components | Free | 3 deps | |
| Compositioncomposition-example | dnd-grid | Components | Free | 3 deps | |
| Constraintsconstraints-example | dnd-grid | Components | Free | 3 deps | |
| Drag from outsidedrag-from-outside-example | dnd-grid | Components | Free | 3 deps | |
| Dynamic add/removedynamic-add-remove-example | dnd-grid | Components | Free | 3 deps |
