Skip to content

FileUpload ​

FileUpload is a drop zone over a native <input type="file">. The input stays in the accessibility tree and is the actual control, so clicking anywhere in the zone opens the OS picker and keyboard users reach it as usual; dragging files onto the zone works through the native drop target. Selected files are listed with their size, a remove button, and an optional per-file Progress bar.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { FileUpload } from '@myghf/ui'

const files = ref<File[]>([])
</script>

<template>
  <FileUpload v-model="files" accept=".pdf,.docx" multiple />
</template>

Examples ​

Multiple files with progress ​

Set multiple to collect several files, and pass progressFor to show a bar per file while it uploads. accept maps to the native attribute (the OS picker filters by it).

Drag and drop files here, or browse

  • referral-letter.pdf234.4 KB
vue
<script setup lang="ts">
import { ref } from 'vue'
import { FileUpload } from '@myghf/ui'

const files = ref<File[]>([
  new File([new Uint8Array(240_000)], 'referral-letter.pdf', {
    type: 'application/pdf',
    lastModified: 1,
  }),
])
</script>

<template>
  <div class="grid max-w-md gap-6">
    <FileUpload v-model="files" accept=".pdf,.docx" multiple :progress-for="() => 60" />
  </div>
</template>

Props ​

PropTypeDefaultDescription
modelValueFile[][]Selected files.
acceptstring—Native accept filter (e.g. '.pdf,.docx' or 'image/*').
multiplebooleanfalseAllow more than one file; new picks append instead of replacing.
disabledbooleanfalseDisables the input.
invalidbooleanfalseMarks the control invalid. Falls through to the FormField context when omitted.
requiredbooleanfalseMarks the control required. Falls through to the FormField context when omitted.
idstring—Applied to the file input so an external <label for> matches.
namestring—Submitted with the owning form as a name/value pair.
promptstring'Drag and drop files here, or'Drop-zone prompt text.
browseLabelstring'browse'Emphasised word appended to the prompt.
removeLabelstring'Remove'Prefix for each file's remove button label.
progressFor(file: File) => number | null—Per-file progress (0–100); null hides the bar.

Events ​

EventPayloadDescription
update:modelValueFile[]The new file list (replace on single, append on multiple).
selectFile[]The files chosen in this interaction (before multiple merging).
removeFileA file removed from the list.

Slots ​

SlotDescription
defaultExtra content inside the drop zone, below the prompt.

Exposed methods ​

None. FileUpload does not call defineExpose.

Accessibility ​

  • The <input type="file"> is the control: it stays focusable and in the accessibility tree (styled opacity-0 over the zone), so it is clickable, droppable, and keyboard reachable without scripting. The zone shows a focus-within ring when the input is focused.
  • Give it an accessible name with a FormField label or an aria-label; inside a FormField the input also picks up id, aria-describedby, aria-invalid, and required through the shared useFieldControl composable.
  • Each listed file's remove button has an aria-label naming the file; the progress bar is a labelled Progress with role="progressbar".

Dark mode & RTL ​

  • The zone and file rows use semantic tokens (bg-surface, border-border, text-muted); the drag highlight uses a primary-50 tint with a dark:bg-primary-900/20 counterpart, so it adapts to dark mode.
  • The layout is direction-safe — logical padding and gap, no physical offsets — so the zone and file rows mirror correctly under dir="rtl".

Released under the MIT License.