</> ConvertAtlas Developer Tools
Bootstrap 5 · Advanced

Drag-to-Reorder List

A list whose items can be dragged to reorder, using native drag events.

Requires Bootstrap 5. Add the CDN tags below to your page (styles in <head>, scripts before </body>). The downloaded file already includes them.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<div class="card border-0 shadow-sm" style="max-width:320px"><div class="card-body">
  <h6 class="fw-bold mb-2">Reorder (drag)</h6>
  <ul class="list-group" id="drList">
    <li class="list-group-item" draggable="true">🟠 First item</li>
    <li class="list-group-item" draggable="true">🔵 Second item</li>
    <li class="list-group-item" draggable="true">🟢 Third item</li>
    <li class="list-group-item" draggable="true">🟣 Fourth item</li>
  </ul>
</div></div>
var list=document.getElementById('drList'),dragged=null;
list.querySelectorAll('li').forEach(function(li){
  li.addEventListener('dragstart',function(){dragged=li;li.style.opacity='.4'});
  li.addEventListener('dragend',function(){li.style.opacity='1'});
  li.addEventListener('dragover',function(e){e.preventDefault();var r=li.getBoundingClientRect();var after=(e.clientY-r.top)/r.height>.5;list.insertBefore(dragged,after?li.nextSibling:li)});
});
Free to use.This component uses Bootstrap 5 (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.