Web component / esm

<form-dropzone>

Import the class and register it explicitly. See the README for the full API.

Image selection and previews

The class-only import does not register the element. After registration, drag images onto the zone or use the native picker. The dashed border becomes solid during a file drag. Without JavaScript, the required APIs, or a successful CDN load, the labeled native picker remains usable, without drag enhancement or previews.

<form-dropzone preview-images>
  <label for="esm-images">Choose images</label>
  <input
    id="esm-images"
    name="images"
    type="file"
    accept="image/*"
    multiple />
</form-dropzone>

<script type="module">
  import { FormDropzoneElement } from 'https://esm.sh/@aarongustafson/form-dropzone@1.0.3/form-dropzone.js?bundle&target=es2022';

  if (!customElements.get('form-dropzone')) {
    customElements.define('form-dropzone', FormDropzoneElement);
  }
</script>