Skip to content

Drop Validation

A copy-paste drag & drop component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

Drag & DropHTMLCSSany framework
Allowed
Not allowed

Copy into your project

HTML
<!-- Drop Validation — show .is-valid or .is-invalid based on dragged type -->
<div class="nuda-dropval">
  <div class="nuda-dropval__zone is-valid">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
         stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
      <path d="M5 12 L10 17 L20 7" />
    </svg>
    <span>Allowed</span>
  </div>
  <div class="nuda-dropval__zone is-invalid">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
         stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
      <path d="M6 6 L18 18" /><path d="M18 6 L6 18" />
    </svg>
    <span>Not allowed</span>
  </div>
</div>
CSS
/* Drop Validation
   Two states for drop targets: valid (accent + glow) / invalid (red + shake).
   Customize: --dv-ok, --dv-bad */

.nuda-dropval {
  --dv-ok: #e4ff54;
  --dv-bad: #ff6363;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 220px;
}

.nuda-dropval__zone {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font: 600 0.875rem ui-sans-serif, system-ui, sans-serif;
  border: 1.5px solid;
  animation: nuda-dv-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nuda-dropval__zone svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  animation: nuda-dv-icon 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s backwards;
}

.nuda-dropval__zone.is-valid {
  background: rgba(228, 255, 84, 0.08);
  border-color: var(--dv-ok);
  color: var(--dv-ok);
  box-shadow: 0 0 12px rgba(228, 255, 84, 0.2);
}

.nuda-dropval__zone.is-invalid {
  background: rgba(255, 99, 99, 0.08);
  border-color: var(--dv-bad);
  color: var(--dv-bad);
  animation:
    nuda-dv-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    nuda-dv-shake 0.3s ease-in-out 0.4s;
}

@keyframes nuda-dv-pop {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes nuda-dv-icon {
  from { opacity: 0; transform: scale(0); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes nuda-dv-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .nuda-dropval__zone,
  .nuda-dropval__zone svg { animation: none; }
}

How to use Drop Validation

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.

More drag & drop components

← Browse all NudaUI components