Skip to Content
snapgrid is a react-grid-layout v2 alternative built on dnd-kit. Drag, resize, repack, and drag between grids.

Examples

Every demo below is the real library running in your browser: drag, resize, and play. Each links to the guide that explains it.

Drag & resize

The basics: drag a tile, resize it from the corner, watch the rest compact upward. → Getting Started

Drag & resize
drag a tile · resize from the corner

Compaction & packing

Swap the packing algorithm at runtime: vertical, horizontal, masonry, gravity, shelf, or free. → Compaction guide

Compaction
swap the packing algorithm, then drag

Resize constraints

Every edge and corner, with per-item minW / maxW / minH / maxH enforced. → Resizing guide

Resize constraints
drag the corner · min/max enforced

Drag handles

Drag only by the grip; the rest of the tile stays interactive. → Dragging guide

Drag handle
only the ⠿ grip starts a drag — the button stays clickable

Snap to grid

Toggle whether the dragged tile glides with the pointer or snaps to cells. → Dragging guide

Snap to grid
toggle whether the dragged tile snaps or glides

Static items

Toggle a tile between locked and pinned (anchored, but still draggable). Others flow around it either way. → Static items guide

Static items
LOCKED: the anchor can't be dragged — others flow around it

Responsive

Columns and layout change as the width crosses breakpoints. → Responsive guide

Responsive
12 columns · 798px — drag the right edge to resize

Cross-grid dragging

Two grids in a SnapGridGroup. Drag tiles between them. → Cross-grid guide

Cross-grid dragging
drag a tile between the two grids

Nested grids

A grid inside another grid’s tile. Drag the panel by its header, rearrange the inner tiles, or drag a tile between the inner and outer grids. → Nesting guide

Nested grids
drag the panel by its header; drag tiles between the inner and outer grids

External drop

Drag a chip from a palette into the grid; the grid synthesizes a new item. → External drop guide

External drop
drag a chip from the palette into the grid

Sortable ↔ grid

The grid interoperates with the wider dnd-kit ecosystem: drag a card from a useSortable tray into the grid (it lands at a real cell), drag a tile back out, or reorder the tray — all under one provider. → dnd-kit interop guide

Sortable ↔ grid
drag a widget into the grid · drag a tile out to the tray · reorder the tray

Component layer

Every example above is headless. This is the turnkey shell: <GridLayout> wires the DragDropProvider, tiles, handles, and placeholder for you. → Component layer guide

Component layer
the turnkey <GridLayout> — no hooks, no dnd-kit wiring
Last updated on