CSS File Drop Zone

A dashed upload area that wraps a real file input, so click and drop both work.

  • file
  • upload
  • dropzone
  • input
  • dashed
HTML
<label class="dropzone">
  <input type="file" multiple>
  <svg viewBox="0 0 24 24" width="28" height="28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 16V4m0 0-4 4m4-4 4 4"/><path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/></svg>
  <span><b>Click to upload</b> or drag files here</span>
</label>
CSS
.dropzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 260px;
  padding: 26px 16px;
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
  color: #64748b;
  font: 14px/1.4 system-ui, sans-serif;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

/* The input covers the whole zone so files can be dropped anywhere on it */
.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone b {
  color: #7c3aed;
}

.dropzone:hover,
.dropzone:has(:focus-visible) {
  border-color: #a78bfa;
  background: #f5f3ff;
  color: #6d28d9;
}

About this CSS File Drop Zone

This CSS File Drop Zone is 35 lines of pure CSS (0.7 KB) with no JavaScript and no dependencies. It uses transitions, CSS Grid, the :has() selector and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #cbd5e1
  • #f8fafc
  • #64748b
  • #7c3aed
  • #a78bfa
  • #f5f3ff
  • #6d28d9

How to use this file drop zone

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .dropzone class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback