04.33 · Micro-Interactions

Drag to Reorder

Drag an item and the others slide aside to make room. Best for to-do lists.

Drag it

Drag a task up or down and let go (or Tab to its grip, then use Space and the arrow keys), or press Show me.

  • Reply to Sam
  • Book the flights
  • Review the draft
  • Water the plants

Press Space to pick up the task, the up and down arrow keys to move it, and Space again to drop it. Escape puts it back.

Try it

Change a setting, then try it again or press Show me.

Slide speed

How fast the other tasks slide out of the way.

How much it lifts

Strong makes the task you hold grow, tilt and cast a deeper shadow.

Only the grip starts a drag, so a finger on the rest of a row still scrolls the page.

Copy the prompt

Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.

Add drag to reorder to [the list whose order people can change]. Lift the picked-up item and let it follow the pointer exactly; as it passes a neighbor's middle, slide that neighbor into the gap, and on release settle it into place and save the order. Shift the items rather than changing the layout, so it stays smooth. Support the keyboard: Space picks up, the arrow keys move, Space drops and Escape cancels, each step read out to screen readers. On touch screens, start a drag at once from the grip; if the rest of an item can start one too, only after a short press, so swipes still scroll. If the visitor has reduced motion turned on, move items straight to their places. Match the settings listed below.

Replace the words in brackets with your own element. Your settings are added at the end.

Free and open source. If this helped, a star on GitHub helps other people find it.

Star on GitHub

What it is

The full explanation is in README.md.

Good for

  • To-do lists
  • Playlists
  • Priority rankings
  • Menu editors

Avoid on

  • Lists sorted by date
  • Very long lists