import BaseUploadFile from "@wikicasa-dev/components/UIKit/BaseUploadFile";
Use to attach a single document in a form: a CV in "Lavora con noi", a floor plan or a deed when publishing a listing. The whole field is the click target; its text comes from the label slot, which receives the chosen filename so you can show it.
It does not upload anything: it emits uploaded with the File, and you handle it. accept and multiple attributes are forwarded to the hidden <input type="file">.
Usage
<script setup lang="ts">
import { ref } from "vue";
import BaseUploadFile from "@wikicasa-dev/components/UIKit/BaseUploadFile";
const floorPlan = ref<File | null>(null);
</script>
<template>
<BaseUploadFile
id="floor-plan-upload"
label-text="Planimetria"
accept="application/pdf, image/*"
:clear="!floorPlan"
@uploaded="(file) => (floorPlan = file)"
>
<template #label="{ filename }">
<span>{{ filename || "Carica un file (PDF o immagine)" }}</span>
</template>
</BaseUploadFile>
<button v-if="floorPlan" type="button" @click="floorPlan = null">Rimuovi</button>
</template>
Do / Don't
- Do pass a unique
id: it links the clickable area to the hidden file input. - Do always fill the
labelslot with a call to action and showfilenameonce chosen; the field is empty otherwise. - Do reset the shown filename by switching
cleartotrue(it emitscleared); switch it back tofalsebefore the next reset. Binding:clear="!file"does this for you. - Don't rely on
multiple: only the first selected file is emitted. - Don't expect validation or error states; show errors next to it yourself.
Styling hooks
classon the wrapper;labelClasseson the clickable area (height 48px, centered text).fieldsetClassesfor the dashed border/background (default lavender fill),legendClasses,floatingLabelClassesfor the floating label.
API
Generated from the component's types. Do not edit by hand.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id |
string |
yes | ||
labelText |
string |
"" |
||
clear |
boolean |
false |
||
labelClasses |
ClassTypeProp |
"" |
||
floatingLabelClasses |
ClassTypeProp |
"" |
||
fieldsetClasses |
ClassTypeProp |
"" |
||
legendClasses |
ClassTypeProp |
"" |
Events
| Name | Payload |
|---|---|
cleared |
|
uploaded |
[File] |
v-model
None.
Slots
| Name | Slot props |
|---|---|
label |
{ filename: string; } |
Exposed (template ref)
None.