
react-grid-dnd
Grid style drag and drop, built with React. See a live example on codesandbox. You can also see it in action here.
Features
- Supports dragging between arbitrary number of lists.
- Built with react-gesture-responder to enable better control over gesture delegation.
- Disable drop targets or dragging altogether
- Animated with react-spring
Install
Install react-grid-dnd
and react-gesture-responder
using yarn or npm.
yarn add react-grid-dnd react-gesture-responder
Usage
Because GridItem
components are rendered with absolute positioning, you need to ensure that GridDropZone
has a specified height or flex, like in the example below.
import GridContextProvider GridDropZone GridItem swap from "react-grid-dnd"; { const items setItems = React; // supply your own state // target id will only be set if dragging from one dropzone to another. { const nextState = ; ; } return <GridContextProvider => <GridDropZone ="items" = = = > items </GridDropZone> </GridContextProvider> ;}
Dragging between lists
You can see this example in action on codesandbox.
import GridContextProvider GridDropZone GridItem swap move from "react-grid-dnd"; { const items setItems = React; { if targetId const result = ; return ; const result = ; return ; } return <GridContextProvider => <div ="container"> <GridDropZone ="dropzone left" ="left" = = > itemsleft </GridDropZone> <GridDropZone ="dropzone right" ="right" = = > itemsright </GridDropZone> </div> </GridContextProvider> ;}