Drag Preview
A copy-paste drag & drop component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.
Drag & DropHTMLCSSany framework
⋮⋮Moving item3
Copy into your project
HTML
<!-- Drag Preview — floating ghost shown while dragging multiple items -->
<div class="nuda-dragprev">
<div class="nuda-dragprev__placeholder"></div>
<div class="nuda-dragprev__ghost">
<span class="nuda-dragprev__handle">⋮⋮</span>
<span>Moving item</span>
<span class="nuda-dragprev__count">3</span>
</div>
</div>CSS
/* Drag Preview
Source spot shows a dashed placeholder; floating ghost tilts and floats.
Use as the visual feedback when starting a drag.
Customize: --dp-accent, --dp-bg */
.nuda-dragprev {
--dp-accent: #e4ff54;
--dp-bg: rgba(20, 20, 24, 0.95);
position: relative;
width: 100%;
max-width: 280px;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
}
.nuda-dragprev__placeholder {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 100%;
height: 36px;
background: rgba(228, 255, 84, 0.08);
border: 1.5px dashed rgba(228, 255, 84, 0.3);
border-radius: 8px;
}
.nuda-dragprev__ghost {
position: relative;
display: flex;
align-items: center;
gap: 10px;
padding: 8px 12px 8px 10px;
background: var(--dp-bg);
border: 1px solid var(--dp-accent);
border-radius: 8px;
font: 500 0.875rem ui-sans-serif, system-ui, sans-serif;
color: #fafafa;
backdrop-filter: blur(8px);
box-shadow:
0 12px 32px -8px rgba(228, 255, 84, 0.3),
0 8px 16px rgba(0, 0, 0, 0.4);
transform: rotate(-2deg) scale(1.04);
animation: nuda-dp-float 2s ease-in-out infinite;
}
.nuda-dragprev__handle {
color: #63636e;
font: 700 0.75rem ui-sans-serif, system-ui, sans-serif;
letter-spacing: -1px;
}
.nuda-dragprev__count {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 18px;
height: 18px;
padding: 0 5px;
background: var(--dp-accent);
color: #09090b;
font: 800 0.6rem ui-sans-serif, system-ui, sans-serif;
border-radius: 5px;
animation: nuda-dp-bump 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes nuda-dp-float {
0%, 100% { transform: rotate(-2deg) scale(1.04) translateY(0); }
50% { transform: rotate(-2deg) scale(1.04) translateY(-4px); }
}
@keyframes nuda-dp-bump {
0% { transform: scale(0.4); }
100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
.nuda-dragprev__ghost { animation: none; }
}How to use Drag Preview
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.