Skip to content
IndexRequest a UIAboutContact

File Drop Zone

A drop area that highlights on drag, validates type and size, and works with Browse and the keyboard.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Clean UI mockup of a file upload drop zone, a large rounded rectangle with a dashed border, an upload cloud icon, the text Drag files here or Browse and a smaller line PNG or JPG up to 2 MB, a second state with a solid blue border, light blue fill and the text Drop to upload, below it a list with one accepted file and one rejected file in red with the reason, light theme, flat modern style. Negative: heavy shadows, clutter, text errors. Reduced motion: static design.

About this pattern

Definition

A drop zone makes uploading feel direct, but dragging is not possible for everyone. The zone should be a real file input underneath, so a click, Enter or Space opens the file picker. While files hover over it, the zone changes style to show it will accept them, and each file is checked for type and size with a clear message.

Purpose & UX principles

  • Wrap a visually hidden input type=file in a label or button so keyboard and screen readers work.
  • Use dragenter, dragover and dragleave to toggle a highlight class; call preventDefault on dragover and drop.
  • Validate type and size before accepting and explain each rejection.
  • List accepted files with size and a remove button.

Interaction states

  • Drag image files in, or press Browse; PNG and JPG up to 2 MB are accepted.

Motion specification

  • The highlight fades over 150ms.
  • Reduced motion: no transition.

Responsive behaviour

  • Avoid flicker by counting dragenter and dragleave pairs, or by checking relatedTarget.
  • Mention accepted types and the size limit in the text of the zone.

Code

HTML
<div class="bx"><label class="dz" id="dz" for="fi"><b>Drag images here</b><span>or <u>Browse</u> · PNG or JPG, up to 2 MB</span><input id="fi" class="sr" type="file" multiple accept="image/png,image/jpeg"></label><ul class="fl" id="fl" aria-label="Files"></ul><p class="out" id="out" role="status"></p></div>

Related patterns

Upload Progress & Retry

↗
Upload Progress & RetryLoading & Progress

Attachment Chips with States

↗
Attachment Chips with StatesAI & Conversational

Hover Reveal Card

↗
Hover Reveal CardCards & Containers