Skip to content

Dropzone

Add files by dragging or browsing; a message names each file that cannot be added and says why.

Drag a file here, or

Maximum file size: 30 MB

<script setup lang="ts">import { ref } from 'vue'import { UiDropzone } from 'grani' const contract = ref<File[]>([])</script> <template>  <UiDropzone    v-model="contract"    accept="application/pdf,.pdf"    :max-size="30 * 1024 * 1024"    ariaLabel="Contract"    class="w-full max-w-96"  /></template>

Also called file upload, file input, drag and drop upload, uploader.

Usage

<UiDropzone v-model="value">…</UiDropzone>

With GraniResolver in the Vite config, a template needs no import: set it up once.

API

Name · typeDefaultDescription
Value
modelValue*File[]The chosen files (v-model); always an array, one entry at most without multiple.
State
busyboolean= falsefalseWork in progress: the rows not yet uploaded carry it, choosing and removing wait until it ends.
Behavior
acceptstringAccepted file types, native accept syntax: image/*, .pdf,.docx, application/pdf.
multipleboolean= falsefalseAllows choosing several files; without it a new file replaces the old one.
maxFilesnumberMaximum number of files, with multiple; ignored without it.
maxSizenumberMaximum file size in bytes; also said under the main line unless #hint is given.
progressnumber | null= nullnullUpload progress 0 to 100 shown with busy; null when unknown. The files listed when it reaches 100 are marked uploaded.
failedstring | boolean= falsefalseThe last upload failed: the rows not uploaded say so, with this reason when it is a string, and offer Retry.
removablefalse | true | auto= "auto""auto"Whether the files can be removed. auto: yes, except the ones a finished upload marked.
Form and access
disabledboolean= falsefalsePrevents choosing, dropping and removing.
invalidboolean= falsefalseMarks the control as invalid. Inside UiField, the error state sets this automatically.
namestringNative name of the file input: a plain form submit sends the listed files.
idstringOwn id when standalone. Inside UiField, the field's id takes precedence.
ariaLabelstringName when there is no visible label; the browse button reads it followed by its own words, "Choose a file" or "Choose files".

Attributes: class and style stay on the outer element; the rest (native attributes, aria-*, data-testid) reach the control inside it.

When to use another component

When you needTake
Names typed or pasted one per lineList field
A typed valueInput
Files already on a recordList item rows in a List, listed without choosing