Skip to content

API Reference

This page contains the complete API reference for Vue3 Dropzone, including all props, events, slots, styling options, and component methods.

Props Reference

Core Configuration

PropTypeDefaultDescription
modelValueArray[]Array of File objects representing newly selected files. Two-way binding with v-model.
previewsArray[]Array of URL strings for existing files/images. Two-way binding with v-model:previews.
modeString"drop"Component behavior mode: "drop" (new files only), "preview" (display only), "edit" (combined functionality).
multipleBooleanfalseAllow selection of multiple files simultaneously.
disabledBooleanfalseCompletely disable all interactions with the dropzone.

File Selection & Strategy

PropTypeDefaultDescription
selectFileStrategyString"replace"How new files interact with existing ones: "replace" (clear existing), "merge" (add to existing).
allowSelectOnPreviewBooleanfalseAllow file selection and removal in preview mode. When true, clicking on empty areas triggers file selection.
ignoreOriginalPreviewsBooleanfalseWhen true and using replace strategy in preview mode, original preview URLs are permanently hidden after new files are selected.
maxFilesNumber5Maximum number of files that can be selected at once.
maxFileSizeNumber5Maximum file size allowed in megabytes (MB).
acceptStringundefinedComma-separated list of allowed file types (MIME types). Example: "image/*,application/pdf".

Visual Layout & Positioning

PropTypeDefaultDescription
widthNumber/StringautoWidth of the dropzone container. Can be px, %, or any CSS unit.
heightNumber/String200pxHeight of the dropzone container. Can be px, %, or any CSS unit.
previewPositionString"inside"Where to display file previews: "inside" (within dropzone), "outside" (below dropzone).
imgWidthNumber/StringautoWidth of individual preview images.
imgHeightNumber/StringautoHeight of individual preview images.
previewWrapperClassesString""Additional CSS classes to apply to the preview container.

User Interface Elements

PropTypeDefaultDescription
showSelectButtonBooleantrueDisplay the "Select File" button within the dropzone interface.
fileInputIdStringauto-generatedCustom ID for the hidden file input element. Auto-generated if not provided.
stateString"indeterminate"Visual state of the dropzone: "indeterminate", "success", "error". Affects border colors.

Server Integration

PropTypeDefaultDescription
serverSideBooleanfalseEnable server-side file upload functionality with progress tracking.
uploadEndpointStringundefinedURL endpoint for file uploads when serverSide is enabled.
deleteEndpointStringundefinedURL endpoint for file deletion when serverSide is enabled.
headersObject{}Additional HTTP headers to send with server requests.

Events Reference

Vue3 Dropzone emits the following events:

EventPayloadDescription
update:modelValueArrayEmitted when the files array changes. Contains File objects.
update:previewsArrayEmitted when the previews array changes. Contains URL strings.
dropEventEmitted when files are dropped onto the dropzone.
fileUploadedObjectEmitted when a file successfully uploads (server-side mode).
fileRemovedObjectEmitted when a File object is removed from the list.
previewRemovedObjectEmitted when a preview URL is removed from the list.
errorObjectEmitted on validation errors or upload failures. Contains error type and files.

Event Examples

vue
<template>
  <Vue3Dropzone
    v-model="files"
    v-model:previews="previews"
    @update:modelValue="onFilesChange"
    @update:previews="onPreviewsChange"
    @drop="onDrop"
    @fileUploaded="onFileUploaded"
    @error="onError"
  />
</template>

<script setup>
import { ref } from 'vue'

const files = ref([])
const previews = ref([])

const onFilesChange = (newFiles) => {
  console.log('Files changed:', newFiles)
}

const onPreviewsChange = (newPreviews) => {
  console.log('Previews changed:', newPreviews)
}

const onDrop = (event) => {
  console.log('Files dropped:', event)
}

const onFileUploaded = (file) => {
  console.log('File uploaded successfully:', file)
}

const onError = (error) => {
  console.error('Upload error:', error)
}
</script>

Slots

Override default content with custom implementations using these slots:

SlotPurpose
placeholder-imgReplace the default placeholder image
titleReplace the default "Drop your files here" title
buttonReplace the default "Select File" button
descriptionReplace the default file requirements description
previewCustom preview item rendering

Slot Examples

vue
<template>
  <!-- Custom placeholder image -->
  <Vue3Dropzone v-model="files">
    <template #placeholder-img>
      <img src="/custom-placeholder.png" alt="Custom placeholder" />
    </template>
  </Vue3Dropzone>

  <!-- Custom title and description -->
  <Vue3Dropzone v-model="files">
    <template #title>
      <h3>Upload Your Documents</h3>
    </template>
    <template #description>
      <p>Drag and drop your files or click to browse</p>
    </template>
  </Vue3Dropzone>

  <!-- Custom preview rendering -->
  <Vue3Dropzone v-model="files" mode="edit">
    <template #preview="{ file, index, remove }">
      <div class="custom-preview">
        <img :src="file.url" :alt="file.name" />
        <button @click="remove" class="remove-btn">✕</button>
      </div>
    </template>
  </Vue3Dropzone>
</template>

Styling & CSS Variables

The component uses CSS custom properties for easy theming. Override them in your CSS to customize the appearance:

css
:root {
  /* Primary colors */
  --v3-dropzone--primary: 94, 112, 210;

  /* State colors */
  --v3-dropzone--success: 36, 179, 100;
  --v3-dropzone--error: 255, 76, 81;

  /* UI colors */
  --v3-dropzone--border: 214, 216, 220;
  --v3-dropzone--description: 190, 191, 195;

  /* Overlay colors */
  --v3-dropzone--overlay: 40, 44, 53;
  --v3-dropzone--overlay-opacity: 0.3;
}

Complete CSS Variables Reference

VariableDefaultPurpose
--v3-dropzone--primary94, 112, 210Primary color (RGB values)
--v3-dropzone--border214, 216, 220Border color (RGB values)
--v3-dropzone--description190, 191, 195Description text color (RGB values)
--v3-dropzone--error255, 76, 81Error state color (RGB values)
--v3-dropzone--success36, 179, 100Success state color (RGB values)
--v3-dropzone--overlay40, 44, 53Overlay background color (RGB values)
--v3-dropzone--overlay-opacity0.3Overlay opacity value

Component Methods

Access these methods via template ref for programmatic control:

MethodParametersDescription
clearFiles()NoneRemove all File objects (new uploads)
clearPreviews()NoneRemove all preview URLs (existing files)
clearAll()NoneRemove both files and previews completely
clearPreview()NoneLegacy method - equivalent to clearAll()

Methods Examples

vue
<template>
  <div>
    <Vue3Dropzone ref="dropzone" v-model="files" />
    <div class="mt-4 space-x-2">
      <button @click="clearNewFiles" class="px-4 py-2 bg-blue-500 text-white rounded">
        Clear New Files
      </button>
      <button @click="clearExistingFiles" class="px-4 py-2 bg-green-500 text-white rounded">
        Clear Existing
      </button>
      <button @click="clearAll" class="px-4 py-2 bg-red-500 text-white rounded">
        Clear All
      </button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const files = ref([])
const dropzone = ref()

const clearNewFiles = () => {
  dropzone.value.clearFiles()
}

const clearExistingFiles = () => {
  dropzone.value.clearPreviews()
}

const clearAll = () => {
  dropzone.value.clearAll()
}
</script>

Made with ❤️ by JaxThePrime