Awesome
<p align="center"> <img src="https://user-images.githubusercontent.com/2182637/53611918-54c1ff80-3c24-11e9-9917-66ac3cef513d.png" alt="react beautiful dnd logo" /> </p> <h1 align="center">@hello-pangea/dnd</h1> <div align="center">Beautiful and accessible drag and drop for lists with React
Play with this example if you want!
</div>Core characteristics
- Beautiful and natural movement of items ๐
- Accessible: powerful keyboard and screen reader support โฟ๏ธ
- Extremely performant ๐
- Clean and powerful api which is simple to get started with
- Plays extremely well with standard browser interactions
- Unopinionated styling
- No creation of additional wrapper dom nodes - flexbox and focus management friendly!
Star History
<a href="https://star-history.com/#hello-pangea/dnd&Date"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=hello-pangea/dnd&type=Date&theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=hello-pangea/dnd&type=Date" /> <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=hello-pangea/dnd&type=Date" /> </picture> </a>Get started ๐ฉโ๐ซ
Alex Reardon has created a free course on egghead.io
๐ฅ (using react-beautiful-dnd) to help you get started with @hello-pangea/dnd
as quickly as possible.
Currently supported feature set โ
- Vertical lists โ
- Horizontal lists โ
- Movement between lists (โค โ โค)
- Virtual list support ๐พ - unlocking 10,000 items @ 60fps
- Combining items
- Mouse ๐ญ, keyboard ๐นโฟ๏ธ and touch ๐๐ฑ (mobile, tablet and so on) support
- Multi drag support
- Incredible screen reader support โฟ๏ธ - we provide an amazing experience for english screen readers out of the box ๐ฆ. We also provide complete customisation control and internationalisation support for those who need it ๐
- Conditional dragging and conditional dropping
- Multiple independent lists on the one page
- Flexible item sizes - the draggable items can have different heights (vertical lists) or widths (horizontal lists)
- Add and remove items during a drag
- Compatible with semantic
<table>
reordering - table pattern - Auto scrolling - automatically scroll containers and the window as required during a drag (even with keyboard ๐ฅ)
- Custom drag handles - you can drag a whole item by just a part of it
- Able to move the dragging item to another element while dragging (clone, portal) - Reparenting your
<Draggable />
- Create scripted drag and drop experiences ๐ฎ
- Allows extensions to support for any input type you like ๐น
- ๐ฒ Tree support through the
@atlaskit/tree
package - A
<Droppable />
list can be a scroll container (without a scrollable parent) or be the child of a scroll container (that also does not have a scrollable parent) - Independent nested lists - a list can be a child of another list, but you cannot drag items from the parent list into a child list
- Server side rendering (SSR) compatible
- Plays well with nested interactive elements by default
Motivation ๐ค
@hello-pangea/dnd
exists to create beautiful drag and drop for lists that anyone can use - even people who cannot see. For a good overview of the history and motivations of the project you can take a look at these external resources:
Not for everyone โ๏ธ
There are a lot of libraries out there that allow for drag and drop interactions within React. Most notable of these is the amazing react-dnd
. It does an incredible job at providing a great set of drag and drop primitives which work especially well with the wildly inconsistent html5 drag and drop feature. @hello-pangea/dnd
is a higher level abstraction specifically built for lists (vertical, horizontal, movement between lists, nested lists and so on). Within that subset of functionality @hello-pangea/dnd
offers a powerful, natural and beautiful drag and drop experience. However, it does not provide the breadth of functionality offered by react-dnd
. One shortcoming is that grid layouts are not supported (yet). So @hello-pangea/dnd
might not be for you depending on what your use case is.
Documentation ๐
About ๐
- Installation
- Examples and samples
- Get started (This is using react-beautiful-dnd)
- Design principles
- Animations
- Accessibility
- Browser support
Sensors ๐
The ways in which somebody can start and control a drag
- Mouse dragging ๐ญ
- Touch dragging ๐๐ฑ
- Keyboard dragging ๐นโฟ๏ธ
- Create your own sensor (allows for any input type as well as scripted experiences)
API ๐๏ธโ
<DragDropContext />
- Wraps the part of your application you want to have drag and drop enabled for<Droppable />
- An area that can be dropped into. Contains<Draggable />
s<Draggable />
- What can be dragged around
Guides ๐บ
<DragDropContext />
responders -onDragStart
,onDragUpdate
,onDragEnd
andonBeforeDragStart
- Combining
<Draggable />
s - Common setup issues
- Using
innerRef
- Setup problem detection and error recovery
- Rules for
draggableId
anddroppableId
s - Browser focus retention
- Customising or skipping the drop animation
- Auto scrolling
- Controlling the screen reader
- Use the html5
doctype
TypeScript
: type information- Dragging
<svg>
s - Avoiding image flickering
- Non-visible preset styles
- How we detect scroll containers
- How we use dom events - Useful if you need to build on top of
@hello-pangea/dnd
- Adding
<Draggable />
s during a drag (11.x behaviour) - โ ๏ธ Advanced - Setting up Content Security Policy
Patterns ๐ทโ
- Virtual lists ๐พ
- Multi drag
- Tables
- Reparenting a
<Draggable />
- Using our cloning API or your own portal
Support ๐ฉโโ๏ธ
Creator โ๏ธ
Alex Reardon @alexandereardon
Alex is no longer personally maintaning this project. The other wonderful maintainers are carrying this project forward.
Maintainers ๐ ๏ธ
- Gabriel Santerre @100terres
- Reece Carolan @Xhale1
- Many @Atlassian's have contributed to the original
react-beautiful-dnd
. Atlassian is no longer involved with this project.
Collaborators ๐ค
- Bogdan Chadkin @IAmTrySound
Thanks ๐ค
<a href="https://www.chromatic.com/"><img src="https://user-images.githubusercontent.com/321738/84662277-e3db4f80-af1b-11ea-88f5-91d67a5e59f6.png" width="153" height="30" alt="Chromatic" /></a>
Thanks to Chromatic for providing the visual testing platform that helps us review UI changes and catch visual regressions.