Dropzone
A file upload dropzone for drag-and-drop or click-based document and media uploads.
import { Dropzone } from "@schukai/monster/source/components/form/dropzone.mjs";Introduction
The Monster Dropzone handles click-based and drag-and-drop uploads in one consistent upload surface. Use it when files, images or documents should be attached through a clear drop area instead of a hidden file input alone.
When to use Dropzone
- Use it for uploads with visual affordance: Users immediately understand where files belong.
- Use it for media and document workflows: Especially useful when multiple upload paths should feel unified.
- Do not use it for tiny hidden uploads: If there is no visible upload workflow, a plain file input may be enough.
Typical mistakes
Make the upload contract clear. Users should know file types, size limits and what happens after upload, otherwise even a visually good dropzone still feels unreliable.
Simple Dropzone
A basic dropzone for multiple files. Auto upload is disabled so you can validate or prepare files before sending them to the server.
Javascript
import '@schukai/monster/source/components/form/dropzone.mjs';
const dropzone = document.querySelector('#dropzone');
dropzone.setOption('features.autoUpload', false);
dropzone.setOption('accept', '.pdf,.png,.jpg,.jpeg');
dropzone.setOption('labels.title', 'Upload documents');
dropzone.setOption('labels.hint', 'or drag and drop them here');
dropzone.setOption('labels.button', 'Choose files');<script type="module">import '@schukai/monster/source/components/form/dropzone.mjs';
const dropzone = document.createElement('monster-dropzone');
dropzone.setOption('features.autoUpload', false);
dropzone.setOption('accept', '.pdf,.png,.jpg,.jpeg');
dropzone.setOption('labels.title', 'Upload documents');
dropzone.setOption('labels.hint', 'or drag and drop them here');
dropzone.setOption('labels.button', 'Choose files');
document.getElementById('dropzone-simple').appendChild(dropzone);</script>HTML
<monster-dropzone id="dropzone"></monster-dropzone>Stylesheet
/** no additional stylesheet is defined **/Profile Image Upload
A single-file dropzone for profile images. File types are restricted to images, and the control shows previews for quick confirmation.
Javascript
import '@schukai/monster/source/components/form/dropzone.mjs';
const dropzone = document.querySelector('#avatar-dropzone');
dropzone.setOption('features.autoUpload', false);
dropzone.setOption('features.previewImages', true);
dropzone.setOption('multiple', false);
dropzone.setOption('accept', 'image/*');
dropzone.setOption('labels.title', 'Upload a profile image');
dropzone.setOption('labels.hint', 'PNG or JPG, max 5 MB');
dropzone.setOption('labels.button', 'Choose image');<script type="module">import '@schukai/monster/source/components/form/dropzone.mjs';
const dropzone = document.createElement('monster-dropzone');
dropzone.setOption('features.autoUpload', false);
dropzone.setOption('features.previewImages', true);
dropzone.setOption('multiple', false);
dropzone.setOption('accept', 'image/*');
dropzone.setOption('labels.title', 'Upload a profile image');
dropzone.setOption('labels.hint', 'PNG or JPG, max 5 MB');
dropzone.setOption('labels.button', 'Choose image');
document.getElementById('dropzone-avatar').appendChild(dropzone);</script>HTML
<monster-dropzone id="avatar-dropzone"></monster-dropzone>Stylesheet
/** no additional stylesheet is defined **/Component Design
The dropzone is implemented with the Shadow DOM, which encapsulates its structure and styling. Customization is enabled through exported parts and theme variables.
Exported Parts
Use the ::part() selector to style the component without breaking encapsulation.
control: Wrapper for the dropzone, status, and list.dropzone: The interactive drag-and-drop area.content: Container for title and hint.title: Title text inside the dropzone.hint: Hint text inside the dropzone.button: The internal action button.input: The hidden file input.status: Upload status line below the dropzone.list: List container for selected files.
monster-dropzone::part(dropzone) {
border-style: solid;
border-color: #c7d2fe;
background-color: #f8faff;
}
monster-dropzone::part(title) {
font-weight: 700;
}
monster-dropzone::part(list) {
margin-top: 1rem;
}
Theme Variables
The component relies on global Monster theme variables. You can override them on the host to align the dropzone with your design system.
monster-dropzone {
--monster-border-radius: 12px;
--monster-bg-color-primary-1: #f5f6f8;
--monster-color-primary-1: #1f2937;
}
HTML Structure
<monster-dropzone></monster-dropzone>JavaScript Initialization
const element = document.createElement('monster-dropzone');
document.body.appendChild(element);Exported
DropzoneDerived from
CustomElementOptions
The Options listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the CustomElement.
- since
- deprecated
Properties and Attributes
The Properties and Attributes listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits Properties and Attributes from these parent classes. If you cannot find a specific Properties and Attributes in this list, we recommend consulting the documentation of the CustomElement.
data-monster-options: Sets the configuration options for the collapse component when used as an HTML attribute.data-monster-option-[name]: Sets the value of the configuration option[name]for the collapse component when used as an HTML attribute.
Methods
The methods listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the CustomElement.
Behavioral methods
open()- {void}
Static methods
[instanceSymbol]()- {symbol}
instanceof operator.getCSSStyleSheet()- {CSSStyleSheet[]}
getTag()- {string}
Lifecycle methods
Lifecycle methods are called by the environment and are usually not intended to be called directly.
[assembleMethodSymbol]()Other methods
upload(files)files{filelist|file[]}: files
- {Promise
}
Events
The component emits the following events:
monster-dropzone-selectedmonster-dropzone-file-addedmonster-dropzone-file-removedmonster-dropzone-file-retrymonster-dropzone-file-upload-startmonster-dropzone-file-upload-successmonster-dropzone-file-upload-errormonster-dropzone-upload-startmonster-dropzone-upload-successmonster-dropzone-upload-error
For more information on how to handle events, see the mdn documentation.