FileUploadField
Form field component to upload files with drag-and-drop support.
Component
Drag and drop a file here
PDF, IMAGE, VIDEO up to 5MB
Example help text
Props
| Props | Required | Default | Type |
|---|---|---|---|
id | true | — | string |
label | — | — | string |
ariaLabel | — | — | string |
title | — | — | string |
helpText | — | — | string |
helpTextPosition | — | Position.BOTTOM | Position |
icon | — | 'mdi:cloud-upload-outline' | string |
buttonText | — | — | string |
singleFileTitleText | — | 'Drag and drop a file here' | string |
replaceTitleText | — | 'Upload a new file to replace current one' | string |
singleFileButtonText | — | 'Select file' | string |
replaceButtonText | — | 'Replace file' | string |
upToText | — | 'up to' | string |
modelValue | — | [] | array |
validator | — | null | function |
error | — | — | string |
disabled | — | false | boolean |
required | — | false | boolean |
showOptionalLabel | — | true | boolean |
optionalLabel | — | — | string |
multiple | — | false | boolean |
accept | — | '*' | string | string[] |
maxFileSize | — | 5 | number |
maxFiles | — | 1 | number |
fileUploadErrorMessage | — | 'The size or format of one ore more files is incorrect.' | string |
showPreview | — | false | boolean |
previewImageUrl | — | — | string |
previewContainerClasses | — | 'w-[120px] h-[120px] min-w-[120px]' | string |
itemsLayout | — | DropzoneLayout.LIST | DropzoneLayout |
state | — | DropzoneState.DEFAULT | DropzoneState |
selectFileStrategy | — | FileSelectStrategy.MERGE | FileSelectStrategy |
showSelectButton | — | true | boolean |
showClearAllButton | — | true | boolean |
clearAllButtonText | — | 'Clear all' | string |
fileTypeIconMap | — | {} | Record<string, string> |
totalProgress | — | 0 | number |
useServerUpload | — | false | boolean |
uploadUrl | — | — | string |
deleteUrl | — | — | string |
uploadHeaders | — | {} | Record<string, string> |
uploadAdditionalData | — | {} | Record<string, string | Blob | number | boolean> |
uploadWithCredentials | — | false | boolean |
uploadingStatusText | — | 'Uploading' | string |
successStatusText | — | 'Uploaded' | string |
errorStatusText | — | 'Upload failed' | string |
pendingStatusText | — | 'Pending' | string |
retryIcon | — | 'mdi:refresh' | string |
removeIcon | — | 'mdi:close' | string |
retryButtonStyleType | — | ButtonStyleType.NEUTRAL_FILLED | ButtonStyleType |
removeButtonStyleType | — | ButtonStyleType.DELETE_FILLED | ButtonStyleType |
retryIconClass | — | — | string | string[] |
removeIconClass | — | — | string | string[] |
retryButtonClass | — | — | string |
removeButtonClass | — | — | string |
maxItemsContainerHeight | — | — | number |
containerClass | — | — | string |
dropzoneClass | — | — | string |
titleClass | — | — | string |
descriptionClass | — | — | string |
iconClass | — | — | string | string[] |
actionsClass | — | — | string |
listClass | — | — | string |
gridClass | — | — | string |
fileItemClass | — | — | string |
fileNameClass | — | — | string |
fileMetaClass | — | — | string |
retryAriaLabel | — | 'Retry upload' | string |
removeAriaLabel | — | 'Remove file' | string |
transparent | — | false | boolean |
Usage
id
Sets the id of the field.
<template>
<FileUploadField id="field-id" />
</template>
label
Sets the label of the field.
<template>
<FileUploadField label="Sample label" />
</template>
ariaLabel
Sets the accessible name passed to the dropzone area when the visual label is hidden.
It is also used as preview image alt fallback.
<template>
<FileUploadField
label=""
ariaLabel="Upload contract files"
/>
</template>
title
Sets the drag and drop area title of the field.
<template>
<FileUploadField title="Field title" />
</template>
helpText
Sets the help text of the field.
<template>
<FileUploadField helpText="Example help text" />
</template>
helpTextPosition
Sets the position of the help text relative to the field. It uses the Position enum.
<template>
<FileUploadField helpTextPosition="top" helpText="Appears above the field" />
</template>
Options
| Value | Description |
|---|---|
TOP | top |
BOTTOM | bottom |
icon
Sets the icon of the drag and drop area.
<template>
<FileUploadField icon="mdi:upload" />
</template>
buttonText
Sets the button text of the field.
<template>
<FileUploadField buttonText="Upload file" />
</template>
singleFileTitleText
Sets the dropzone title used when multiple is false.
<template>
<FileUploadField singleFileTitleText="Drag and drop a file here" />
</template>
replaceTitleText
Sets the dropzone title shown when preview mode is active and the field is in replace mode.
<template>
<FileUploadField replaceTitleText="Upload a new file to replace current one" />
</template>
singleFileButtonText
Sets the select button text used when multiple is false.
<template>
<FileUploadField singleFileButtonText="Select file" />
</template>
replaceButtonText
Sets the select button text shown when preview mode is active and the field is in replace mode.
<template>
<FileUploadField replaceButtonText="Replace file" />
</template>
upToText
Sets the "up to" text shown next to the maximum file size.
<template>
<FileUploadField upToText="up to" />
</template>
modelValue
Binds the selected files to the field.
<template>
<FileUploadField v-model="files" />
</template>
<script setup lang="ts">
const files = ref<File[]>([])
</script>
validator
Sets the validator function for the field, which controls its internal validation state.
Since this field expects an array value, the validateArrayField utility should be used to perform required field validation.
<template>
<FileUploadField :validator="validateArrayField" />
</template>
error (v-model:error)
Defines the error message displayed by the field. This prop is bindable via v-model:error, allowing two-way syncing of the validation state.
<template>
<FileUploadField v-model:error="errorMessage" />
</template>
disabled
Sets the disabled state of the field.
<template>
<FileUploadField disabled />
</template>
required
Sets the required state of the field.
<template>
<FileUploadField required />
</template>
showOptionalLabel
When the field is not required, shows an "(optional)" hint next to the label. Set to false to hide it. The hint text defaults to a global setting that can be overridden project-wide, and can also be overridden per field with the optionalLabel prop.
<template>
<FileUploadField label="Attachment" :showOptionalLabel="false" />
</template>
optionalLabel
Overrides the "(optional)" hint text for this specific field, taking priority over the global default.
<template>
<FileUploadField label="Attachment" optionalLabel="(not required)" />
</template>
multiple
Sets whether multiple file selection is allowed.
<template>
<FileUploadField multiple />
</template>
accept
Sets the accepted file types for upload. It can be a string or an array of strings.
<template>
<FileUploadField accept="image/*" />
</template>
maxFileSize
Sets the maximum file size (in MB) allowed for each uploaded file.
<template>
<FileUploadField :maxFileSize="5" />
</template>
maxFiles
Sets the maximum number of files that can be uploaded.
<template>
<FileUploadField :maxFiles="1" />
</template>
fileUploadErrorMessage
Sets the error message displayed when one or more files fail validation.
<template>
<FileUploadField fileUploadErrorMessage="File upload failed" />
</template>
showPreview
Sets whether to show a preview of the uploaded file.
<template>
<FileUploadField showPreview />
</template>
previewImageUrl
Sets the URL of the image to be shown in the preview.
<template>
<FileUploadField
showPreview
previewImageUrl="https://example.com/image.jpg"
/>
</template>
previewContainerClasses
Sets the CSS classes for the preview container.
<template>
<FileUploadField
showPreview
previewContainerClasses="w-[150px] h-[150px]"
/>
</template>
itemsLayout
Sets how uploaded items are rendered (LIST or GRID).
<template>
<FileUploadField itemsLayout="grid" />
</template>
state
Sets the visual dropzone state (DEFAULT, INDETERMINATE, SUCCESS, ERROR).
<template>
<FileUploadField state="success" />
</template>
selectFileStrategy
Sets how new files are handled when files already exist (MERGE or REPLACE).
<template>
<FileUploadField selectFileStrategy="replace" multiple />
</template>
showSelectButton
Controls visibility of the select files button.
<template>
<FileUploadField :showSelectButton="false" />
</template>
showClearAllButton
Controls visibility of the clear all button.
<template>
<FileUploadField :showClearAllButton="false" />
</template>
clearAllButtonText
Sets clear all button text.
<template>
<FileUploadField clearAllButtonText="Remove all" />
</template>
fileTypeIconMap
Overrides default icon mapping by file type/extension key.
<template>
<FileUploadField :fileTypeIconMap="{ pdf: 'mdi:file-pdf-box', geo: 'mdi:map-outline' }" />
</template>
totalProgress
Two-way bound overall upload progress value with v-model:totalProgress. This value is used to update the progress bar shown in the dropzone when useServerUpload is true.
<template>
<FileUploadField v-model:totalProgress="totalProgress" />
</template>
<script setup lang="ts">
const totalProgress = ref(0)
</script>
useServerUpload
Enables server-side upload mode.
<template>
<FileUploadField
useServerUpload
uploadUrl="/api/uploads"
deleteUrl="/api/uploads"
/>
</template>
uploadUrl
Server endpoint used to upload files.
<template>
<FileUploadField useServerUpload uploadUrl="/api/uploads" />
</template>
deleteUrl
Server endpoint used to delete uploaded files.
<template>
<FileUploadField useServerUpload deleteUrl="/api/uploads" />
</template>
uploadHeaders
Custom headers used for upload and delete requests.
<template>
<FileUploadField :uploadHeaders="{ Authorization: 'Bearer token' }" />
</template>
uploadAdditionalData
Additional key-value pairs appended to upload FormData.
<template>
<FileUploadField :uploadAdditionalData="{ module: 'documents', public: true }" />
</template>
uploadWithCredentials
Sends upload requests with credentials.
<template>
<FileUploadField useServerUpload uploadWithCredentials />
</template>
uploadingStatusText
Text used while a file is uploading.
<template>
<FileUploadField uploadingStatusText="Uploading file" />
</template>
successStatusText
Text used after a successful upload.
<template>
<FileUploadField successStatusText="Done" />
</template>
errorStatusText
Text used after a failed upload.
<template>
<FileUploadField errorStatusText="Try again" />
</template>
pendingStatusText
Text used for files waiting to upload.
<template>
<FileUploadField pendingStatusText="Waiting" />
</template>
retryIcon
Icon used by the retry action button.
<template>
<FileUploadField retryIcon="mdi:reload" />
</template>
removeIcon
Icon used by the remove action button.
<template>
<FileUploadField removeIcon="mdi:trash-can-outline" />
</template>
retryButtonStyleType
Style variant used by the retry action button.
<template>
<FileUploadField retryButtonStyleType="neutral-transparent" />
</template>
removeButtonStyleType
Style variant used by the remove action button.
<template>
<FileUploadField removeButtonStyleType="delete-transparent" />
</template>
retryIconClass
Custom class or class list applied to retry icon.
<template>
<FileUploadField retryIconClass="text-text-default" />
</template>
removeIconClass
Custom class or class list applied to remove icon.
<template>
<FileUploadField :removeIconClass="['text-text-error', 'opacity-90']" />
</template>
retryButtonClass
Custom class applied to retry button wrapper.
<template>
<FileUploadField retryButtonClass="rounded-md" />
</template>
removeButtonClass
Custom class applied to remove button wrapper.
<template>
<FileUploadField removeButtonClass="rounded-md" />
</template>
maxItemsContainerHeight
Sets max height in pixels for the list items container before vertical scrolling.
<template>
<FileUploadField :maxItemsContainerHeight="280" />
</template>
containerClass
Custom class for the root Dropzone container.
<template>
<FileUploadField containerClass="bg-background-neutral-subtlest" />
</template>
dropzoneClass
Custom class for the drag-and-drop area.
<template>
<FileUploadField dropzoneClass="border-border-success" />
</template>
titleClass
Custom class for the dropzone title.
<template>
<FileUploadField titleClass="text-text-primary" />
</template>
descriptionClass
Custom class for the dropzone description.
<template>
<FileUploadField descriptionClass="text-text-neutral-subtle" />
</template>
iconClass
Custom class or class list for the dropzone icon.
<template>
<FileUploadField :iconClass="['text-icon-default', 'opacity-80']" />
</template>
actionsClass
Custom class for the actions container.
<template>
<FileUploadField actionsClass="justify-start" />
</template>
listClass
Custom class for list layout container.
<template>
<FileUploadField listClass="gap-3" />
</template>
gridClass
Custom class for grid layout container.
<template>
<FileUploadField itemsLayout="grid" gridClass="gap-4" />
</template>
fileItemClass
Custom class for each file item card.
<template>
<FileUploadField fileItemClass="shadow-xs" />
</template>
fileNameClass
Custom class for file name text.
<template>
<FileUploadField fileNameClass="text-sm" />
</template>
fileMetaClass
Custom class for file metadata text.
<template>
<FileUploadField fileMetaClass="text-xs" />
</template>
retryAriaLabel
Sets the accessible label for the retry action button on each file item. Useful for i18n.
<template>
<FileUploadField retryAriaLabel="Reintentar subida" />
</template>
removeAriaLabel
Sets the accessible label for the remove action button on each file item. Useful for i18n.
<template>
<FileUploadField removeAriaLabel="Eliminar archivo" />
</template>
transparent
When true, passes transparent to the child Dropzone, removing its state background and showing only the border.
<template>
<FileUploadField transparent />
</template>
Emits
| Props | Type |
|---|---|
update:totalProgress | (value: number) => void |
error | (message: string) => void |
file-added | (file: File) => void |
file-removed | (file: File) => void |
clear-all | (files: File[]) => void |