Skip to content

FileInput ​

A file picker: a button that opens the file dialog, the chosen file names, a clear button, and a drop target for files dragged onto the field. The model is a File (or null) by default and a File[] with multiple; read the contents with file.text() or file.arrayBuffer().

Examples ​

Single file ​

accept takes the native syntax (extensions and MIME types). The dialog filters by it, and so does the drop target: a dropped file that does not match is reported under the field and in the rejected event.

Case data
No file chosen

vue
<script setup>
import { ref, watch } from "vue";
const file = ref(null);
watch(file, async (f) => {
  if (f) console.log(await f.text());
});
</script>

<FileInput
  v-model="file"
  label="Case data"
  hint="A CSV with a date column and a count column"
  accept=".csv,text/csv"
/>

Multiple files ​

Scenario files
Drop parameter files here
vue
<script setup>
import { ref } from "vue";
const files = ref([]);
</script>

<FileInput
  v-model="files"
  label="Scenario files"
  multiple
  accept=".json,.yaml,.yml,.toml"
  placeholder="Drop parameter files here"
/>

Set :dropzone="false" to turn the drop target off, and button-label to rename the button.

Model ​

NameType
v-modelFile | File[] | null

Props ​

PropTypeRequiredDefault
labelstringNo—
hideLabelbooleanNo—
ariaLabelstringNo—
hintstringNo—
acceptstringNo—
multiplebooleanNo—
disabledbooleanNo—
buttonLabelstringNo—
placeholderstringNo—
dropzonebooleanNotrue

Events ​

EventPayload
rejectedFile[]