Drag-to-Reorder Rows
A copy-paste drag & drop component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.
Drag & DropHTMLCSSany framework
Grab a row's handle and press Alt plus Arrow Up or Arrow Down to reorder.
Invoice #221
Invoice #222
Invoice #223
Copy into your project
HTML
<!-- Drag-to-Reorder Rows — a div-based grid (role="table"/"row"/"cell")
so the drag lift can animate transform freely. Toggle --drag on the
grabbed row and --gap on the row that yields space.
Keyboard: focus a row, Alt+ArrowUp/ArrowDown reorders. -->
<div class="nuda-dd2-table-rows" role="table" aria-label="Reorderable invoices" aria-describedby="dd2-table-rows-desc">
<p id="dd2-table-rows-desc" class="nuda-dd2-table-rows__sr">Grab a row's handle and press Alt plus Arrow Up or Arrow Down to reorder.</p>
<div class="nuda-dd2-table-rows__row" role="row">
<span class="nuda-dd2-table-rows__handle" aria-hidden="true">⋮⋮</span>
<span class="nuda-dd2-table-rows__cell" role="cell">Invoice #221</span>
</div>
<div class="nuda-dd2-table-rows__row nuda-dd2-table-rows__row--gap" role="row">
<span class="nuda-dd2-table-rows__handle" aria-hidden="true">⋮⋮</span>
<span class="nuda-dd2-table-rows__cell" role="cell">Invoice #222</span>
</div>
<div class="nuda-dd2-table-rows__row nuda-dd2-table-rows__row--drag" role="row" tabindex="0">
<span class="nuda-dd2-table-rows__handle" aria-hidden="true">⋮⋮</span>
<span class="nuda-dd2-table-rows__cell" role="cell">Invoice #223</span>
</div>
</div>CSS
.nuda-dd2-table-rows {
width: 180px;
display: flex;
flex-direction: column;
gap: 5px;
}
.nuda-dd2-table-rows__sr {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0,0,0,0);
white-space: nowrap;
border: 0;
}
.nuda-dd2-table-rows__row {
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
background: #141414;
border-bottom: 1px solid rgba(255,255,255,.06);
}
.nuda-dd2-table-rows__row:focus-visible {
outline: 2px solid #e4ff54;
outline-offset: 2px;
}
.nuda-dd2-table-rows__handle {
color: #63636e;
font: 700 9px ui-sans-serif,system-ui;
letter-spacing: -1px;
}
.nuda-dd2-table-rows__cell {
font: 500 11px ui-sans-serif,system-ui;
color: #cfcfcf;
}
.nuda-dd2-table-rows__row--gap {
animation: nuda-dd2-table-rows-gap 2.7s ease-in-out infinite;
}
.nuda-dd2-table-rows__row--drag {
position: relative;
z-index: 2;
background: #1c1c1c;
border-bottom-color: transparent;
animation: nuda-dd2-table-rows-drag 2.7s ease-in-out infinite;
}
.nuda-dd2-table-rows__row--drag .nuda-dd2-table-rows__handle {
color: #e4ff54;
}
@keyframes nuda-dd2-table-rows-drag {
0%,14%,100% {
transform: translateY(0);
box-shadow: none;
}
40%,74% {
transform: translateY(-12px);
box-shadow: 0 10px 20px -8px rgba(0,0,0,.5),0 0 0 1px rgba(228,255,84,.4);
}
}
@keyframes nuda-dd2-table-rows-gap {
0%,14%,100% {
transform: translateY(0);
}
40%,74% {
transform: translateY(12px);
}
}
@media (prefers-reduced-motion:reduce) {
.nuda-dd2-table-rows__row--gap,.nuda-dd2-table-rows__row--drag {
animation: none;
}
}
How to use Drag-to-Reorder Rows
Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.
Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.