DEV Community


Posted on

How to make a component draggable but, in which I can drag it from a drag icon only?

I'm trying to create a draggable component in which when I drag <DragIndicatorIcon/> the whole component will be dragged but when I shouldn't be able to drag the component when the mouse is down on the div.

import React from 'react'
import DragIndicatorIcon from '@material-ui/icons/DragIndicator';

function Drag() {
      return (
            <div draggable style={{ display: 'flex' }} >
                  <DragIndicatorIcon />
                  <div  >Drag me from the icon don't drag me from my text please.</div>

export default Drag

Top comments (0)