Skip to content

FileInput API Reference

Props

PropTypeDefaultDescription
labelStringBased on multipleLabel for the file input
maxFilesNumber-Maximum number of files that can be selected
maxSizeNumber-Maximum file size in bytes
multipleBooleanfalseAllow selection of multiple files
modelValueObject/Array-v-model binding value
valueObject/Array-Alternative to modelValue
chipBooleanfalseDisplay selected files as chips
persistentDetailsBooleantrueAlways show validation details
acceptString-File types to accept (e.g., ".jpg,.png")

Events

The component emits many standard DOM events, including:

EventPayloadDescription
update:modelValueFile/FilesEmitted when files are selected or removed
changeEventEmitted when files change
focusEventEmitted when input receives focus
blurEventEmitted when input loses focus
dragenterEventEmitted when drag enters the component
dragoverEventEmitted when drag is over the component
dragleaveEventEmitted when drag leaves the component
dropEventEmitted when files are dropped

Slots

SlotPropsDescription
prepend{ props }Content before the input
append-inner{ props }Content inside the input, at the end
append{ props }Content after the input

Methods

The component doesn't explicitly expose methods via template refs.

Example Usage

vue
<template>
  <OFileInput
    v-model="files"
    label="Upload Documents"
    :multiple="true"
    :maxFiles="5"
    :maxSize="5000000"
    accept=".pdf,.docx,.txt"
    :chip="true"
    @update:modelValue="handleFilesChange"
  />
</template>

<script setup>
import { ref } from 'vue'
import { OFileInput } from 'your-component-library'

const files = ref([])

const handleFilesChange = (newFiles) => {
  console.log('Files selected:', newFiles)
}
</script>

Validation

The component performs validation on:

  • Maximum number of files
  • Maximum file size
  • File type (based on the accept prop)

Error messages are displayed when validation fails.