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

API Overview

A map of the public surface. Follow a link for details.

@snapgridjs/react

The main package. Components, hooks, and a re-export of the engine types.

Components

ExportPurpose
GridLayoutDrop-in controlled grid with keyed children.
ResponsiveGridLayoutPer-breakpoint layouts.
GridItemA positioned tile with default markup + handles.
GridPlaceholderDefault landing-cell marker.
GridDragOverlayFloating drag preview (body portal).
SnapGridProviderHeadless provider — owns the session.
SnapGridGroupWraps grids for cross-grid dragging.

Hooks

ExportReturns
useContainerWidth{ width, mounted, containerRef }
useGridContainer{ containerProps, isDropTarget }
useGridItem{ ref, style, isDragging, item }
useGridResizeHandle{ ref, handleProps, isResizing }
useGridPlaceholder{ item, style } | null
useGridDragOverlay{ item, style } | null
useResponsiveLayout{ breakpoint, cols, layout, onLayoutChange }

Utilities & compactors

DEFAULT_BREAKPOINTS, DEFAULT_BREAKPOINT_COLS, and the built-in compactors verticalCompactor, horizontalCompactor, noCompactor, getCompactor.

Types & config

Layout, LayoutItem, GridConfig, DragConfig, ResizeConfig, DropConfig, GridDropData, GridEventCallback, Compactor, CompactType, Breakpoints, BreakpointCols, ResponsiveLayouts, PositionParams, ResizeHandleAxis. See Types & config.

@snapgridjs/core

The framework-agnostic engine: geometry, move/resize/insert/remove operations, and the drag session state machine. Most apps never import it directly. See Core engine & extras.

@snapgridjs/extras

Optional packers: masonryCompactor, gravityCompactor, shelfCompactor, plus wrapCompactor and the fast O(n log n) compactors re-exported from react-grid-layout. See Core engine & extras.

Last updated on