React-Draggable

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

Library
npm
v4.7.1
9,290stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
79/100Good
Development Activity76
Maintenance68
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture82
Code Quality78
Innovation68
Learning Curve85

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 13 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

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

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,010

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
61
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 1 months ago
JavaScript
53%
Other

Cosmos-Server

Security · Authentication

6,121

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
79
Repo Health
59
Technical
66
Dependency
Built with
JavaScript53%
Go43%
Updated yesterday
TypeScript
48%
AGPL 3.0

Grafana

Monitoring · Analytics

76,300

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
65
Dependency
Built with
TypeScript48%
Go46%
Updated today
Go
61%
Apache 2.0

Harness Open Source

Developer Tools · Devops · Code Editors

38,017

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
65
Dependency
Built with
Go61%
TypeScript34%
Updated 2 days ago
TypeScript
99%
AGPL 3.0

Karakeep

Bookmarks Archiving

28,454

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
67
Dependency
Built with
TypeScript99%
Updated 3 days ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Marketing · Automation

2,618

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

View details
53
Repo Health
66
Technical
64
Dependency
Built with
TypeScript94%
Updated 1 months ago
Python
58%
Apache 2.0

MLflow

AI Development · Monitoring

27,573

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
68
Dependency
Built with
Python58%
TypeScript33%
Updated today
TypeScript
99%
Other

Papermark

Digital Signiture · File Storage

8,952

Open-source DocSend alternative with page-by-page analytics, secure data rooms, and custom domains for document sharing.

View details
86
Repo Health
63
Technical
68
Dependency
Built with
TypeScript99%
Updated yesterday

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

Search