Drag and Drop

Why Trust Techopedia

What is Drag And Drop?

Drag and drop is a graphical user interface (GUI) function that allows users to move a digital object from one location to another with a simple pointer gesture.


Drag and drop is commonly used for tasks like rearranging desktop icons, moving files, and designing web pages.

Drag and drop is natively supported by HTML5 and most operating systems (OS), but it needs to be deliberately programmed into software applications.

In some use cases, drag and drop functionality can also be used to resize images and manipulate their orientation.

Image explaining the meaning of drag and drop

Key Takeaways

  • Drag and drop allows you to virtually grab a digital object and slide it over to a new location.
  • Drag and drop is natively supported by HTML5 and most operating systems.
  • Software applications do not support drag and drop natively. The functionality needs to be programmed by developers.
  • Drag and drop operations typically have visual cues such as ghost images or highlighted drop zones to help users position the dragged object accurately.
  • Low-code/no-code (LCNC) software platforms allow non-programmers to design software and websites visually by dragging and dropping prewritten software modules.

History of Drag And Drop

Drag and drop definitions are tightly coupled with the development of graphical user interfaces. The Xerox PARC Alto computer, which was developed in the 1970s, is often credited with pioneering drag and drop.

In 1984, Apple introduced drag and drop interactions in the Macintosh operating system (Mac OS), and by the early 1990s, Microsoft Windows also included drag and drop functionality.

Since then, drag and drop has been incorporated into a wide variety of software tools, productivity applications, and web development frameworks. Today, most Windows, macOS, iOS, Android, Linux operating systems, and web browsers support drag and drop functionality to varying degrees.

How Drag And Drop Works

Here’s how to drag and drop a file on a Mac computer or Windows desktop:

  • Move the pointer (mouse, stylus, or finger) to the file you want to move.
  • Press and hold the pointer to grab the file.
  • Drag the file to the new location.
  • Release the pointer to drop the file in the new location.

Does Drag and Drop Work on All Devices?

While the functionality is widely supported by operating systems and browsers, drag and drop’s meaning is not consistent across all devices and applications.

The specific implementation of drag and drop within custom-built applications can vary widely depending on the developer‘s choices. For example, React developers might leverage libraries like react-beautiful-dnd or react-dnd to simplify the implementation and provide a consistent experience across different browsers.

Key Components of Drag And Drop

Drag and drop is made up of several key components that work together.

The main components are object components (elements that can be moved or manipulated), target components (places where objects can be dropped), gesture components (user actions for picking up and releasing an object), visual clues (ghost images that indicate an object is being dragged), and drop logic (underlying code that determines whether an object can be dragged and where it can be dropped).

Image highlighting the key components of drag and drop

Drag And Drop Applications

Drag and drop applications are software programs that allow users to drag and drop elements within the GUI.

Examples include:

Graphic Design Software

Programs like Adobe Photoshop, Adobe Illustrator, and Canva allow users to drag and drop images, shapes, and text to create and arrange designs.

Website Builders

Platforms such as Wix, Squarespace, and WordPress offer drag and drop interfaces for building and customizing web pages without needing to write code. Drag and drop website builders are a popular choice for non-technical users who want to create websites and populate web pages without needing to know how to code.

Email Clients

Email services like Gmail and Outlook allow users to drag and drop emails into folders or onto calendars.

Project Management Tools

Applications like Trello and Asana use drag and drop to move tasks between Kanban columns.

Low-Code/No-Code Platforms

LCNC software development tools like Microsoft Power Apps, OutSystems, and Bubble allow users with varying technical expertise to drag and drop pre-built software modules instead of writing code.

Game Development Engines

Software like Unity and Unreal Engine allow software developers to drag and drop game objects and assets within the game development environment.

How is Drag and Drop Implemented in Programming?

Sometimes, developers have to add drag and drop functionality manually by writing it into code.

This requires developers to:

  1. Identify what elements will be draggable.
  2. Use event listeners (also called event handlers) to specify the dragging process and provide visual clues.
  3. Identify the targets where elements can be dropped.
  4. Add event listeners to manage the drop process.
  5. Implement logic for what action(s) should be performed when an element is dropped.

Image detailing steps to implement drag and drop

Web Development

  • Add the draggable=”true” attribute to HTML elements that can be dragged.
  • Attach JavaScript event listeners for dragstart, drag, dragover, dragenter, dragleave, drop, and dragend
  • Use the dataTransfer object to manage data being dragged and dropped.
  • Update the cascading style sheet to show visual clues.
  • Write JavaScript functions to handle the drop event, validate the drop target and perform designated actions like moving or copying elements.

Mobile Applications

iOS (Swift/Objective-C):

  • Use the UIDragInteraction and UIDropInteraction classes to enable drag and drop on views.
  • Conform to the UIDragInteractionDelegate protocol to handle the start of a drag.
  • Conform to the UIDropInteractionDelegate protocol to handle the drop operation.

Android (Java/Kotlin)

  • Attach a OnDragListener to elements that will accept drops.
  • Use startDragAndDrop() to initiate a drag.
  • Override onDrag() method to handle drag and drop events.

Low Code/No Code Platforms

  • Use prebuilt drag-and-drop components provided by the platform.
  • If necessary, configure interactions to define what happens when an item is dragged and dropped.

Best Practices for Using Drag and Drop

Ideally, drag and drop operations should mimic the physical movement and the functionality providing users with a visual clue (also referred to as visual feedback) for each step in the drag/drop process.

Best practices include providing keyboard alternatives, giving the user the ability to undo or cancel a drag and drop operation, and thoroughly testing the functionality across different devices and browsers.

Drag And Drop Pros and Cons

Drag and drop is an intuitive, visual way for users to interact with digital objects, but its implementation can be challenging for mobile device users who use their fingers or a stylus as their pointing device.

Different mobile browsers have varying levels of support for the HTML5 drag and drop application programming interfaces (APIs), which can create inconsistencies in how drag and drop behaves across different platforms and devices.

The Bottom Line

Drag and drop allows users to virtually grab a digital element and slide it to a new location without needing to know how to code the interaction or use a contextual menu. It is a useful feature in operating systems, web browsers, and a wide variety of software applications.


What is Drag And Drop in simple terms?

What is the purpose of the drag and drop?

What is the difference between drag and drag and drop?

What is an example of a drag and drop?

What is drag and drop on a computer?

How do I drag and drop a file?


Related Terms

Margaret Rouse

Margaret jest nagradzaną technical writerką, nauczycielką i wykładowczynią. Jest znana z tego, że potrafi w prostych słowach pzybliżyć złożone pojęcia techniczne słuchaczom ze świata biznesu. Od dwudziestu lat jej definicje pojęć z dziedziny IT są publikowane przez Que w encyklopedii terminów technologicznych, a także cytowane w artykułach ukazujących się w New York Times, w magazynie Time, USA Today, ZDNet, a także w magazynach PC i Discovery. Margaret dołączyła do zespołu Techopedii w roku 2011. Margaret lubi pomagać znaleźć wspólny język specjalistom ze świata biznesu i IT. W swojej pracy, jak sama mówi, buduje mosty między tymi dwiema domenami, w ten…