Dragology: declarative, composable drag-and-drop for SVG in ReactNote · digest for November 24
Security engineer's desk with a studio still life of cryptographic security artifacts and a clean verification monitor free of third-party trackers
Note3 sections≈ 4 min

Dragology: declarative, composable drag-and-drop for SVG in React

Building a regular Kanban board in React is easy—grab @dnd-kit and cards glide between columns. Graph nodes, chart sliders, or interactive SVG diagrams are a different story. DOM libraries fall short there: you end up wiring pointerdown and pointermove by hand, converting coordinates for SVG scaling, checking drop zones, and coding snap-back animations. The code balloons and breaks on the first resize.

Dragology tackles this pain with a young TypeScript library for React 18 and 19. It grew out of the Declarative Dragging paper by Joshua Horowitz, Andrew Blinn, and Jeffrey Heer (Best Paper Award at UIST 2026). Instead of writing pointer math, you declare valid data states and let the engine handle geometry and motion.

How model-driven dragging works under the hood

Imperative drag-and-drop is like pushing a toy train across a table by hand while watching every millimeter so it doesn't fall off. With Dragology, you lay down tracks and mark the stations the train can visit. That's model-driven dragging: a shape's position is always tied to a real model state rather than arbitrary pixels under the cursor.

Under the hood, it uses speculative rendering. When a user grabs an SVG node, the engine pre-renders shape positions off-screen for reachable target states. It then uses D3 modules (d3-delaunay, d3-interpolate, d3-interpolate-path) and Immer for immutable updates. From those computed points, it builds a Voronoi diagram: the system picks the state closest to the cursor and smoothly interpolates SVG paths.

Diagram of how Declarative Dragging works: model, render, target states, and drag synthesis (Source: declarative-dragging.github.io)

A whole layer of fragile code disappears: snapping boundaries and smooth return animations work out of the box.

Minimal code: an SVG slider in React

The package is on npm under the MIT license and installs with one command (requires React 18 or 19):

npm install dragology

You describe a scene with a Draggable<State> function that receives state and combinators d. Any draggable node needs a unique id and a dragologyOnDrag prop, and DraggableRenderer mounts the scene.

import {
  Draggable, DraggableRenderer, inOrder, param, translate,
} from "dragology";

// Continuous SVG slider in the [0..240] range
type SliderState = { value: number };

const slider: Draggable<SliderState> = ({ state, d }) => (
  <g transform={translate(20, 50)}>
    <line x1={0} y1={0} x2={240} y2={0} stroke="#9ca3af" strokeWidth={4} />
    <circle
      id="thumb"
      r={14}
      fill="#3b82f6"
      transform={translate(state.value, 0)}
      dragologyOnDrag={() =>
        d.vary(state, param("value"), {
          constraint: (s) => inOrder([0, s.value, 240]),
        })
      }
    />
  </g>
);

export function SliderDemo() {
  return (
    <DraggableRenderer
      draggable={slider}
      initialState={{ value: 60 }}
      width={280}
      height={100}
    />
  );
}

Here, d.vary smoothly adjusts value within inOrder([0, s.value, 240]). For a discrete toggle, you can use d.between([{ status: "off" }, { status: "on" }]), and combinators compose cleanly: a sortable list only needs d.closest(candidateStates).withFloating() and dragologyZIndex so the item floats under the cursor and snaps to the nearest slot.

Project status and honest limitations

The repository launched on October 29, 2026. In one month it reached 833 stars and 33 forks with 5 contributors, and the latest npm version is 0.2.0. Before 1.0, the API may still change, and there is no full method reference yet.

Where to explore Dragology before docs arrive

Start at declarative-dragging.github.io, play with the interactive demos, and read src/demos. A Vite + React 19 starter lives in examples/consumer, and there is a docs/AGENTS.md guide for AI agents. Run the local playground with pnpm install && pnpm run dev.

For standard HTML lists and Kanban boards, mature DOM libraries remain more practical—Dragology is built strictly for SVG scenes. Because of speculative rendering, large diagrams also need a bounded set of reachable states so the engine doesn't precompute too much. Still, for prototypes, charts, diagram editors, and educational visuals, it already eliminates a ton of manual work.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 4