Moey Icons
No results. Try “dialog”, “dark” or “grid”.
Moey extras

Dropzone

Drag files in, paste them, or click to choose. It's a real file input underneath — forms, required and the keyboard work even without JavaScript.

<label class="dropzone" data-moey-max-size="5MB" data-moey-max-files="4">
  <input type="file" name="photos" multiple accept="image/*,.pdf">
  <i class="mi mi-cloud-upload dropzone-icon"></i>
  <span class="dropzone-title">Drop files here or <u>browse</u></span>
  <span class="dropzone-hint">Images or PDF · up to 5 MB each · 4 files at most</span>
</label>
  • Drag files onto it — while you drag over the page, every dropzone lights up a little, and the one under the pointer lights up fully.
  • Click it, or Tab to it and press Enter, to open the file picker. Paste () works while it has focus.
  • With multiple, new files are added to the ones already chosen (the browser alone would replace them). The same file twice is skipped.
  • Files that don't fit accept, data-moey-max-size or data-moey-max-files appear in the list with the reason, and aren't sent.
  • Images get a thumbnail; every file can be removed with its ✕.

Compact

.dropzone-sm fits in a form, like any other field.

Attachments
<label class="dropzone dropzone-sm">
  <input type="file" name="attachments" multiple>
  <i class="mi mi-paperclip dropzone-icon"></i>
  <span class="dropzone-text">
    <span class="dropzone-title">Attach files or <u>browse</u></span>
    <span class="dropzone-hint">Up to 10 MB each</span>
  </span>
</label>

A single image

.dropzone-image shows the picture inside the zone — for logos, avatars and covers. Hover to change it. It is square; give it another shape with an aspect-* utility (aspect-video, aspect-4/3 …).

<label class="dropzone dropzone-image aspect-video">
  <input type="file" name="cover" accept="image/*">
  <i class="mi mi-image dropzone-icon"></i>
  <span class="dropzone-title"><u>Choose a cover</u></span>
</label>

Upload progress

Moey doesn’t upload for you — but moey:files hands you each file with its list item, so showing progress is a few lines. Here the "upload" is pretend:

zone.addEventListener('moey:files', (e) => {
  for (const { file, element } of e.detail.items) {
    if (element.classList.contains('is-done')) continue;
    element.classList.add('is-uploading');
    upload(file, (percent) => element.querySelector('progress').value = percent)
      .then(() => element.classList.replace('is-uploading', 'is-done'));
  }
});

Colors

The icon, the link and the drag highlight follow theme-<color>.

<label class="dropzone theme-purple">…</label>

From code & events

Moey.dropzone(zone);          // → the chosen File objects
Moey.dropzone(zone, []);      // clear (or pass files to replace them)

zone.addEventListener('moey:files', (e) => e.detail.files);                  // after every change
zone.addEventListener('moey:reject', (e) => {                                // a file didn't fit
  console.log(e.detail.file.name, e.detail.reason);
  // e.preventDefault() — don't list it
Class / attributeWhat it does
.dropzone on a <label> + <input type="file">The zone. .dropzone-icon, .dropzone-title (a <u> inside is the "browse" link), .dropzone-hint
multiple · accept · required · disabledPlain input attributes — Moey respects them all
data-moey-max-size="5MB" · data-moey-max-files="4"Limits per file and in total
data-moey-list="#id" · data-moey-list="false"Where the file list goes (default: right after the zone) · no list
.dropzone-sm · .dropzone-image (+ aspect-*)Compact row · one previewed picture (square unless an aspect utility says otherwise)
.dropzone-file + .is-uploading / .is-done / .is-errorStates of a listed file, for your upload code