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

Installation

Packages

snapgrid is a small monorepo. Pick what you need:

PackageWhat it isWhen you need it
@snapgridjs/reactReact components + hooks. Pulls in @snapgridjs/core.Always. This is the main entry point.
@snapgridjs/coreFramework-agnostic layout engine (move/resize/compaction, geometry).Installed automatically with @snapgridjs/react. Depend on it directly only for custom non-React integrations.
@snapgridjs/extrasOptional packers: masonry, gravity, shelf, wrap.Only if you use those packing styles.

Install

pnpm add @snapgridjs/react @dnd-kit/react @dnd-kit/dom

Peer dependencies

snapgrid drives the interaction through dnd-kit, which you install alongside it:

  • @dnd-kit/react: the React bindings (useDraggable, DragDropProvider).
  • @dnd-kit/dom: the DOM sensors and feedback plugins.
  • react and react-dom 18 or 19.

snapgrid is built on dnd-kit’s latest framework-agnostic architecture (@dnd-kit/react / @dnd-kit/dom), the line dnd-kit now recommends  over the legacy @dnd-kit/core. snapgrid wraps it behind a single seam in @snapgridjs/core, so your app only ever imports from @snapgridjs/*.

No stylesheet to import

snapgrid ships zero CSS. Components return positioning styles inline and a handful of stable class names / data attributes for you to target. There is no import "@snapgridjs/react/styles.css" step. See Styling for the hooks you can style against.

Framework notes

  • Vite / CRA / plain React: nothing special; it just works.
  • Next.js / Remix (SSR): fully supported. useContainerWidth is SSR-safe and renders at an initial width on the server, then measures on the client. See Server-side rendering.
  • TypeScript: snapgrid is written in TypeScript and ships its own types. No @types/* needed.
Last updated on