# File Drop Zone

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

- Category: [CSS Form Elements](https://copy-css.com/category/forms)
- Tags: file, upload, dropzone, input, dashed
- Live preview: https://copy-css.com/snippets/file-drop-zone
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```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

```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;
}
```

## Notes

- 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.
- the :has() selector: Chrome 105+, Safari 15.4+, Firefox 121+.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
