React-Draggable

A simple, dependency-free React component for making any element draggable.

Library
npm
v4.7.2
9,286 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
79 /100 Good
Development Activity 80
Maintenance 64
Community 72
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 82
Code Quality 78
Innovation 68
Learning Curve 85

React-Draggable wraps an existing element and adds drag event handlers and CSS-transform-based positioning, without inserting any wrapper DOM node. Because it moves elements with CSS transforms rather than absolute-position offsets, dragging works regardless of the element’s original positioning scheme (relative, absolute, or static), and elements can be repositioned between drags without visual glitches.

The package ships two components: <Draggable>, a batteries-included component that manages its own position state, class names, and styling; and <DraggableCore>, a headless variant that exposes the same drag callbacks without applying any transforms or managing state, intended for libraries like react-resizable and react-grid-layout that need full control over positioning.

What You Get

  • A <Draggable> component that wraps a child element and makes it draggable via CSS transforms, with no extra DOM nodes inserted
  • A headless <DraggableCore> component exposing drag start/move/stop callbacks without managing position state or styles
  • Configurable drag axis, bounds, grid-snapping, and a custom drag handle or cancel selector
  • Controlled and uncontrolled positioning modes, with onDrag/onStart/onStop callbacks carrying delta and absolute coordinates
  • Content Security Policy support via a nonce prop or opt-out of the injected user-select style
  • Bundled TypeScript type definitions

Common Use Cases

  • Draggable modals, panels, or floating widgets in dashboard and admin UIs
  • Building custom drag-and-drop or free-form layout tools on top of <DraggableCore>
  • Powering higher-level grid layout libraries such as react-grid-layout and react-resizable
  • Draggable annotation handles or markers in canvas/SVG-based editors
  • Kanban-style or whiteboard-style interfaces where elements need free positioning within bounds

Under The Hood

Architecture - <Draggable> (lib/Draggable.tsx) is a stateful wrapper around <DraggableCore> (lib/DraggableCore.tsx), the low-level component that attaches pointer/mouse/touch event listeners directly to the child DOM node (obtained via the required nodeRef) and computes position deltas on every move event. <Draggable> layers position state, CSS class name toggling (react-draggable, -dragging, -dragged), and CSS-transform application on top of the callbacks <DraggableCore> provides, while <DraggableCore> itself renders no additional markup and applies no transforms, leaving positioning entirely to the caller — this split is what lets react-grid-layout and react-resizable reuse the drag mechanics with their own layout logic.

Tech Stack - The library is authored in TypeScript (lib/*.tsx) and built with tsup into CJS, ESM, and a minified UMD/web bundle (build/web/react-draggable.min.js) referenced by the unpkg field for CDN usage. It has no runtime dependencies beyond React itself (peer dependency), keeping the installed footprint minimal. Tests run under Vitest, including a browser-mode configuration (vitest.browser.config.js) for real DOM/pointer-event behavior alongside the standard jsdom suite.

Code Quality - The test/ directory covers both components’ props and callback behavior, with yarn test:all running the standard suite plus a real-browser pass, indicating explicit attention to drag interactions that are hard to fully verify in jsdom alone. ESLint (flat config) and TypeScript’s tsc --noEmit typecheck are wired into make lint, and the maintainers track a versioned React-compatibility table (2.x through 4.x) in the README, showing deliberate handling of breaking changes across React major versions.

API Design - The API favors minimal ceremony: wrapping a single <div> in <Draggable> is enough to make it draggable, and the required nodeRef prop (replacing the deprecated findDOMNode pattern) is the main piece of boilerplate needed for React Strict Mode compatibility. Prop naming is consistent between the two components (axis, bounds, handle, cancel, onDrag/onStart/onStop), and the README documents a Content Security Policy escape hatch (nonce prop or enableUserSelectHack={false}) that many comparable libraries omit entirely.

Used by 14 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
Go
49%
Other

Cosmos-Server

Authentication · Security

6,167

All-in-one self-hosted home server with SmartShield anti-DDoS, Nebula mesh VPN, automatic HTTPS, and a 250-app marketplace — all secured behind a unified auth layer.

View details
83
Repo Health
59
Technical
64
Dependency
Built with
Go 49%
JavaScript 48%
Updated 2 weeks ago
TypeScript
48%
AGPL 3.0

Grafana

Analytics · Monitoring

76,962

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
63
Dependency
Built with
TypeScript 48%
Go 46%
Updated 5 days ago
Go
62%
Apache 2.0

Harness Open Source

Code Editors · Developer Tools · Devops

38,450

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
89
Repo Health
79
Technical
64
Dependency
Built with
Go 62%
TypeScript 33%
Updated 1 weeks ago
TypeScript
98%
AGPL 3.0

Karakeep

Bookmarks Archiving

29,321

Self-hosted bookmark manager that captures links, notes, images, and PDFs with AI tagging, full-text search, and automatic archiving.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,626

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
51
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 2 months ago
TypeScript
44%
Other

Magic

AI Agents · Automation · Low Code Platforms

5,043

Magic is an enterprise-grade open-source AI agent platform combining a generalist AI agent, workflow engine, IM, and collaborative office system for running an AI-powered digital workforce.

View details
70
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 44%
PHP 32%
Updated 1 months ago
Python
58%
Apache 2.0

MLflow

AI Development · Monitoring

28,154

The open source AI engineering platform for debugging, evaluating, monitoring, and optimizing production LLMs and agents at scale.

View details
97
Repo Health
86
Technical
66
Dependency
Built with
Python 58%
TypeScript 33%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers