Responsive layout
dnd-grid/responsive-exampleFreeComponent
Breakpoint layouts based on container width.
Install it
npx shadcn@latest add https://dnd-grid.com/r/responsive-example.jsonSource
1"use client";23import { ResponsiveDndGrid, type ResponsiveLayouts } from "@dnd-grid/react";45const layouts: ResponsiveLayouts = {6 lg: [7 { id: "a", x: 0, y: 0, w: 6, h: 2 },8 { id: "b", x: 6, y: 0, w: 3, h: 2 },9 { id: "c", x: 9, y: 0, w: 3, h: 2 },10 { id: "d", x: 0, y: 2, w: 12, h: 2 },11 ],12 sm: [13 { id: "a", x: 0, y: 0, w: 4, h: 2 },14 { id: "b", x: 0, y: 2, w: 4, h: 2 },15 { id: "c", x: 0, y: 4, w: 4, h: 2 },16 { id: "d", x: 0, y: 6, w: 4, h: 2 },17 ],18};1920const cards = ["a", "b", "c", "d"];2122export function ResponsiveExample() {23 return (24 <ResponsiveDndGrid25 containerPadding={{ lg: 16, sm: 12 }}26 gap={{ lg: 16, sm: 12 }}27 layouts={layouts}28 rowHeight={48}29 >30 {cards.map((id) => (31 <div key={id}>{id}</div>32 ))}33 </ResponsiveDndGrid>34 );35}
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 | |
| Basic examplebasic-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 |
