Keyboard shortcut: Ctrl + K
Get started

File input

VFileInput selects files through a native dialog or drag and drop. The model is always a File[].

Usage

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput } from 'vectis-ui'

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

<template>
  <VFileInput v-model="files" label="Attachment" />
</template>

Examples

Label and hint

Name the field with label. Use hint to describe accepted files.

vue

Drop a file on the field, or use the paperclip

contract.pdfannex.pdf

An icon at the start, the paperclip at the end

<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput } from 'vectis-ui'
import { search } from 'vectis-ui/icons'

const attachment = ref<File[]>([])
const found = ref<File[]>([
  new File(['x'], 'contract.pdf', { type: 'application/pdf' }),
  new File(['x'], 'annex.pdf', { type: 'application/pdf' }),
])
</script>

<template>
  <div class="column">
    <VFileInput
      v-model="attachment"
      label="Attachment"
      hint="Drop a file on the field, or use the paperclip"
      placeholder="No file chosen yet"
    />

    <VFileInput
      v-model="found"
      multiple
      display="chip"
      :icon-start="search"
      label="Search the attachments"
      hint="An icon at the start, the paperclip at the end"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Sizes

size sets the field size.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput } from 'vectis-ui'

const rows = ref(
  (['sm', 'md', 'lg'] as const).map((size) => ({
    key: size,
    size,
    label: size,
    files: [] as File[],
  })),
)
</script>

<template>
  <div class="column">
    <VFileInput
      v-for="row in rows"
      :key="row.key"
      v-model="row.files"
      :size="row.size"
      :label="row.label"
      multiple
      display="chip"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Multiple files

multiple allows several files. Without it, extra files are rejected.

vue

Drop two and the second is turned away

The model is a File array either way, so nothing downstream has to branch

0 files
<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput } from 'vectis-ui'

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

<template>
  <div class="column">
    <VFileInput
      v-model="one"
      label="One file, the default"
      hint="Drop two and the second is turned away"
    />

    <VFileInput
      v-model="several"
      multiple
      display="chip"
      counter
      label="Several files"
      hint="The model is a File array either way, so nothing downstream has to branch"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Clearable

clearable adds a button to empty the selection.

vue

Add a file: the cross appears to the left of the paperclip

Files then come out one chip at a time

<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput } from 'vectis-ui'

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

<template>
  <div class="column">
    <VFileInput
      v-model="withCross"
      clearable
      multiple
      display="chip"
      label="Clearable"
      hint="Add a file: the cross appears to the left of the paperclip"
    />

    <VFileInput
      v-model="withoutCross"
      multiple
      display="chip"
      label="Not clearable, the default"
      hint="Files then come out one chip at a time"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Display

With multiple files, display chooses comma-separated names or removable chips. A single file always appears as text.

vue

The names joined by commas, on one line

quarterly-report.pdfbalance-sh…l-v3.xlsx

One dismissible chip each, cut in the middle so the extension survives

quarterly-report.pdfbalance-sh…l-v3.xlsx
<script setup lang="ts">
import { ref } from 'vue'
import { VChip, VFileInput } from 'vectis-ui'
import { description, picture_as_pdf as pictureAsPdf } from 'vectis-ui/icons'

const start = () => [
  new File(['x'], 'quarterly-report.pdf', { type: 'application/pdf' }),
  new File(['x'], 'balance-sheet-2026-final-v3.xlsx'),
]

const asText = ref(start())
const asChips = ref(start())
const custom = ref(start())
</script>

<template>
  <div class="column">
    <VFileInput
      v-model="asText"
      multiple
      label="text, the default"
      hint="The names joined by commas, on one line"
    />

    <VFileInput
      v-model="asChips"
      multiple
      display="chip"
      label="chip"
      hint="One dismissible chip each, cut in the middle so the extension survives"
    />

    <VFileInput v-model="custom" multiple display="chip" label="a chip of your own">
      <template #chip="{ file, label, remove, size }">
        <VChip
          :icon-start="file.type === 'application/pdf' ? pictureAsPdf : description"
          :size="size"
          :dismiss-label="`Remove ${file.name}`"
          variant="outline"
          tone="accent"
          dismissible
          @dismiss="remove"
        >
          {{ label }}
        </VChip>
      </template>
    </VFileInput>
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

Per-file limits

accept filters file types and maxSize limits each file in bytes. Each refused file emits reject. Include extensions when MIME types may be missing.

vue

Images and PDFs, 500 kB each at most

<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput, type FileRejection } from 'vectis-ui'

const files = ref<File[]>([])
const refused = ref<FileRejection[]>([])

const reasons: Record<string, string> = {
  type: 'wrong kind of file',
  size: 'too big on its own',
  count: 'too many files',
  'total-size': 'too much altogether',
}

function onReject(rejection: FileRejection) {
  refused.value = [rejection, ...refused.value].slice(0, 4)
}
</script>

<template>
  <div class="column">
    <VFileInput
      v-model="files"
      accept="image/*,.pdf"
      :max-size="500_000"
      multiple
      display="chip"
      label="Receipts"
      hint="Images and PDFs, 500 kB each at most"
      @reject="onReject"
    />

    <output v-if="refused.length" class="refused" aria-label="Files turned away">
      <span v-for="item in refused" :key="item.file.name + item.reason">
        {{ item.file.name }}: {{ reasons[item.reason] }}
      </span>
    </output>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-3);
  max-inline-size: 26rem;
}
.refused {
  display: grid;
  gap: var(--vectis-space-1);
  font-size: var(--vectis-text-body-sm-size);
  color: var(--vectis-color-danger-text);
}
</style>

Selection limits

maxFiles and maxTotalSize limit the whole selection, including existing files.

vue

Three files at most, 1 MB altogether

0 files
<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput, type FileRejection } from 'vectis-ui'

const files = ref<File[]>([])
const refused = ref<FileRejection[]>([])

const reasons: Record<string, string> = {
  type: 'wrong kind of file',
  size: 'too big on its own',
  count: 'that would be a fourth file',
  'total-size': 'that would take the batch over 1 MB',
}

function onReject(rejection: FileRejection) {
  refused.value = [rejection, ...refused.value].slice(0, 4)
}
</script>

<template>
  <div class="column">
    <VFileInput
      v-model="files"
      :max-files="3"
      :max-total-size="1_000_000"
      multiple
      display="chip"
      counter
      clearable
      label="Invoices"
      hint="Three files at most, 1 MB altogether"
      @reject="onReject"
    />

    <output v-if="refused.length" class="refused" aria-label="Files turned away">
      <span v-for="item in refused" :key="item.file.name + item.reason">
        {{ item.file.name }}: {{ reasons[item.reason] }}
      </span>
    </output>
  </div>
</template>

<style scoped>
.column {
  display: grid;
  gap: var(--vectis-space-3);
  max-inline-size: 26rem;
}
.refused {
  display: grid;
  gap: var(--vectis-space-1);
  font-size: var(--vectis-text-body-sm-size);
  color: var(--vectis-color-danger-text);
}
</style>

Counter

counter shows the file count and total size. Its slot receives text, count and bytes.

vue
quarterly-report.pdfcover-photo.jpg

It sits under the field, to the right of this line

2 files (336 kB)
quarterly-report.pdfcover-photo.jpg
2 of 5 · 336 kB
<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput } from 'vectis-ui'

const start = () => [
  new File([new Uint8Array(240_000)], 'quarterly-report.pdf', { type: 'application/pdf' }),
  new File([new Uint8Array(96_000)], 'cover-photo.jpg', { type: 'image/jpeg' }),
]

const standard = ref(start())
const custom = ref(start())
</script>

<template>
  <div class="column">
    <VFileInput
      v-model="standard"
      counter
      multiple
      display="chip"
      label="The counter as it comes"
      hint="It sits under the field, to the right of this line"
    />

    <VFileInput v-model="custom" counter multiple display="chip" label="A wording of your own">
      <template #counter="{ count, bytes }">
        <span class="own">{{ count }} of 5 · {{ Math.round(bytes / 1000) }} kB</span>
      </template>
    </VFileInput>
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
.own {
  font-variant-numeric: tabular-nums;
}
</style>

Custom icon

Replace the file dialog icon with pickerIcon.

vue

pickerIcon takes the same values as every icon prop in the library

Naming the icon after what the field accepts says more than a paperclip

<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput } from 'vectis-ui'
import { cloud_upload as cloudUpload, image } from 'vectis-ui/icons'

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

<template>
  <div class="column">
    <VFileInput
      v-model="documents"
      :picker-icon="cloudUpload"
      multiple
      display="chip"
      label="Documents"
      hint="pickerIcon takes the same values as every icon prop in the library"
    />

    <VFileInput
      v-model="photos"
      :picker-icon="image"
      accept="image/*"
      multiple
      display="chip"
      label="Photos"
      hint="Naming the icon after what the field accepts says more than a paperclip"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

States

readonly prevents selection and removal. noDrop disables only drag and drop. loading shows a spinner without disabling selection.

vue

For a rule of your own: nothing here is checked by the browser

What was chosen stays on show, and no dialog, drop or removal will change it

Greyed through the colour tokens, and out of the tab order

Loading…

A spinner where the paperclip was, and nothing else changes

The paperclip still opens the dialog: only dropping is turned away

<script setup lang="ts">
import { ref } from 'vue'
import { VFileInput } from 'vectis-ui'

const chosen = () => [new File(['x'], 'contract.pdf', { type: 'application/pdf' })]

const invalid = ref(chosen())
const readOnly = ref(chosen())
const disabled = ref(chosen())
const noDrop = ref<File[]>([])
const uploading = ref(chosen())
</script>

<template>
  <div class="column">
    <VFileInput
      v-model="invalid"
      invalid
      display="chip"
      label="Invalid"
      hint="For a rule of your own: nothing here is checked by the browser"
    />

    <VFileInput
      v-model="readOnly"
      readonly
      display="chip"
      label="Read-only"
      hint="What was chosen stays on show, and no dialog, drop or removal will change it"
    />

    <VFileInput
      v-model="disabled"
      disabled
      display="chip"
      label="Disabled"
      hint="Greyed through the colour tokens, and out of the tab order"
    />

    <VFileInput
      v-model="uploading"
      loading
      display="chip"
      label="Uploading"
      hint="A spinner where the paperclip was, and nothing else changes"
    />

    <VFileInput
      v-model="noDrop"
      no-drop
      multiple
      display="chip"
      label="Drop refused"
      hint="The paperclip still opens the dialog: only dropping is turned away"
    />
  </div>
</template>

<style scoped>
.column {
  display: flex;
  flex-direction: column;
  gap: var(--vectis-space-5);
  max-inline-size: 26rem;
}
</style>

API

Props

PropTypeDefault
multiplebooleanfalse
Allows multiple files. Otherwise, extra files are rejected.
acceptstringnone
Accepted file types, using native syntax such as image/*,.pdf. Filters dialog selections and dropped files.
displayFileInputDisplay'chip' | 'text''text'
Multiple-file display: text or removable chips. Single files always use text.
maxSizenumbernone
Maximum size per file, in bytes.
maxTotalSizenumbernone
Maximum total selection size, in bytes.
maxFilesnumbernone
Maximum number of selected files.
counterbooleanfalse
Shows the file count and total size below the field.
pickerIconIconSourceattach_file
Icon of the button opening the file dialog.
noDropbooleanfalse
Disables drag and drop; dialog selection remains available.
sizeFileInputSize'sm' | 'md' | 'lg''md'
Component size.
disabledbooleanfalse
Disables interaction.
readonlybooleanfalse
Prevents opening the dialog, dropping files and removing them. Controls remain focusable.
invalidbooleanfalse
Marks the control as invalid and applies the error style. Validate your file selection separately.
labelstringnone
Visible label. Without a visible name, provide aria-label or aria-labelledby.
hintstringnone
Help text linked through aria-describedby.
errorstringnone
Error message shown in place of the hint. Sets aria-invalid, is linked through aria-describedby and is announced when it appears.
requiredbooleanfalse
Adds an asterisk after the label and announces the field as required. The browser does not check it: validate the selection and set error.
hideLabelbooleanfalse
Hides the label visually while keeping it as the accessible name.
labelPositionFieldLabelPosition'top' | 'start''top'
Places the label above the field or beside it.
placeholderstringnone
Text shown when the selection is empty. Defaults to the library dictionary.
iconStartIconSourcenone
Start icon. A @click:icon-start listener makes it a button; provide iconStartLabel.
iconStartLabelstringnone
Accessible name of the start icon button.
pickerLabelstringnone
Accessible name of the file dialog button. Defaults to the library dictionary.
loadingbooleanfalse
Shows a spinner without disabling selection or drag and drop.
loadingTextstringnone
Loading text and accessible spinner name. Defaults to the library dictionary.
clearablebooleanfalse
Adds a button to empty the selection.
clearLabelstringnone
Accessible name of the clear button. Defaults to the library dictionary.
v-modelFile[][]
Selected files as a File[], even for a single file.

Events

EventType
click:icon-start[event: MouseEvent]
The start icon button was clicked.
clear[]
The selection was cleared; the model is already empty.
change[files: File[]]
The selection changed. Receives the complete File[].
reject[rejection: FileRejection]
Emitted for each rejected file. Receives the file and a reason: type, size, count or total-size.
remove[file: File, index: number]
A chip removed a file. Receives the file and index; followed by change.

Slots

SlotType
start{}
Content after iconStart.
value-end{}
Content before the clear and file dialog buttons.
chipFileInputChipSlotProps
File chip content. Receives the file, shortened label, remove, size and density.
counterFileInputCounterSlotProps
Counter content. Receives localized text, count and total size in bytes.

Types

Types used in the API tables. Import exported types from vectis-ui.

export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export type ChipSize = 'xs' | 'sm'
export interface FileInputChipSlotProps {
  file: File
  index: number
  label: string
  remove: () => void
  size: ChipSize
}
export interface FileInputCounterSlotProps {
  count: number
  bytes: number
  text: string
}
export type FileRejectReason = 'type' | 'size' | 'count' | 'total-size'
export interface FileRejection {
  file: File
  reason: FileRejectReason
}
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender