adobe stock icon Download 10 Free Photos & Assets From Adobe Stock Download Now

10 CSS & JavaScript Snippets for Creating Drag-and-Drop UIs

on CSS & UI Design

Drag-and-drop has been with us for decades. It helps us to get things done on both our desktop and mobile apps and operating systems. There’s both a simplicity and intuitiveness that have become one of the most universal UI features.

So it’s no wonder that drag-and-drop has invaded the web over the past few years. From uploading files in Dropbox to sorting our Trello boards – its usefulness has been proven repeatedly.

There are a number of creative ways we can implement these interfaces into our own designs. Let’s take a look at 10 unique examples of drag-and-drop UI:

Learn the Basics

Before you can go really in-depth with implementing drag-and-drop, it’s important to learn some fundamentals. That’s where this simple snippet that utilizes Angular can come in handy. It’s a basic exercise in dragging a square element from one side of the screen to the other. An alert pops up when you’re finished. Nothing fancy, but it could be useful for grasping the concepts involved.

Draggable Panels

Speaking of Trello, the task management tracker’s implementation of drag-and-drop is incredibly useful. Here’s an example that stays pretty faithful to what makes Trello so cool. You can drag panels from column to column, and there’s an awesome color-changing effect when something is moved to a new spot.

Build Your Own Kaleidoscope?

This is example is both quite breathtaking and a bit trippy. It utilizes HTML 5 Canvas and some JavaScript to create a movement-aware kaleidoscope. But wait, there’s more! You can also drag an image into the UI, thus changing the image displayed within the kaleidoscope. All I can say is, “far out.”

Drag a Simple Page Element

On our desktop or laptop computers, we sometimes want to move a specific element off to the side. It’s still in view – but out of the way of other, more important items. That’s exactly what this dead-simple jQuery button does for the web. Move it to anywhere on the screen for later viewing.

HTML5 Drag-and-Drop API

Did you know that HTML5 has its own drag-and-drop API? I ask only because I had no clue. Here, it’s combined with some JavaScript to enable the swapping of squares. While this is a simple example, it shows the potential of tapping into the API.

Form Builder

We often see drag-and-drop used with forms. A WordPress Plugin like Gravity Forms comes to mind, where fields can be added and repositioned quite intuitively. Here we have a form builder UI that uses HTML5 and Angular.js.

Scalable Pixel Art

Adding images via drag-and-drop is quite common. But, like the kaleidoscope above, this snippet provides a unique use case. You can drag an image into a specified div, and it creates CSS-based pixel art that can be scaled to up to 20x the original size. It also outputs CSS code to paste into your project – a good representation of how useful this UI can be.

Easily Add Events

The ability to rearrange data is a prime use of dragging. This calendar example shows how we can use the UI to place events on specific dates and even switch between dates, if necessary. Furthermore, it shows how implementing drag-and-drop can take the pain points out of common tasks.

It’s a Knockout

The file upload field has been around for years. But drag-and-drop makes it so much more user-friendly. Here we have a couple of example fields using Knockout.js. The first allows for dragging a single file, the other allowing for multiple uploads. But both offer a preview of the file, adding further visual confirmation to the UI.

Moving From a Scrollable Container

This is one we don’t see very often. The scrollable container at the top of this snippet contains boxes that can be moved to another div down below. It shows that a scrollable interface can be quite usable in this type of scenario.

Dragging You Towards a Better UI

There are several ways that a drag-and-drop UI can benefit the user-friendliness of your website. Hopefully, the examples above will provide you with some inspiration regarding how you can use this familiar feature to enhance your projects.

Related Tags