Description
react-draggable is a small React component for making elements draggable. It wraps an existing element and adds drag handlers and styles to it, without creating an extra wrapper element in the DOM. Items are moved with CSS transforms, so they can be dragged whatever their current positioning is, whether relative, absolute or static, and they can be moved between drags without trouble. If the dragged element already has a CSS transform, react-draggable overwrites it, so the README suggests an intermediate wrapper in that case. The Draggable component has many props. You can set the axis to both, x, y or none, restrict movement with bounds, which accepts parent, a CSS selector or explicit edges, snap to a grid, and choose a handle or a cancel selector to decide what starts or stops a drag. Other props set the starting position, disable dragging, and control the class names applied while an element is dragged, and the README covers DraggableCore, nodeRef for React Strict Mode, controlled and uncontrolled use, and Content Security Policy nonces. TypeScript types are included. The package supports React 16.3 and newer in version 4, React 15 to 16 in version 3, and React 0.14 to 15 in version 2. Its README links to a demo and a changelog.…
Highlights
- Makes elements draggable without adding a wrapper element
- Moves items with CSS transforms
- Axis, bounds, grid snapping and drag handles
- Includes TypeScript types and supports React 16.3 and newer
Ratings & Reviews
No ratings yet
Be the first to rate react-draggable.
People also visit
react-draggable FAQ
What does react-draggable do?
It makes an existing element draggable in React, by adding drag handlers and styles to it.
Does it add an extra element to the page?
No. The README says it does not create a wrapper element in the DOM.
Which React version do I need?
Version 4.x supports React 16.3 and newer, version 3.x supports React 15 to 16, and version 2.x supports React 0.14 to 15.
Can I limit where an element can be dragged?
Yes. The bounds prop accepts parent, a CSS selector or explicit left, top, right and bottom values.
Does it have TypeScript types?
Yes. The README says TypeScript types are included.
What are the best react-draggable alternatives?
Popular alternatives to react-draggable include react-resizable-and-movable, react-drag-and-drop and react-dnd. See all react-draggable alternatives




















