WlFilePicker
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Button size.
Button density.
Extensions or MIME types for the file picker. The application validates files.
Default button label; falls back to WlConfig.locale.chooseFiles (Choose files in English).
Default button accessible name.
Allows multiple file selection.
Disables the trigger and choose().
Props pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Example
Choose files. Connect server upload in your application.
Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.
Code for your application
Vue SFC · current settings
<script setup lang="ts">
import { WlButton, WlFilePicker } from "legato-ui";
import { ref } from "vue";
const files = ref<File[]>([]);
const message = ref("Choose files. Connect server upload in your application.");
function select(next: File[]): void {
files.value = next;
message.value = `${"Selected: "}${next.map((file) => file.name).join(", ")}`;
}
function reset(): void {
files.value = [];
message.value = "You can choose files again.";
}
</script>
<template>
<div class="wl-stack" data-space="md">
<WlFilePicker
multiple
accept=".pdf,.txt"
@select="select"
@cancel="message = 'Selection cancelled. The file list has not changed.'"
/>
<p class="wl-text-small" role="status">{{ message }}</p>
<WlButton v-if="files.length" size="sm" @click="reset">{{ "Clear list" }}</WlButton>
</div>
</template>Selecting multiple files
Custom trigger, ref methods, select/cancel, standard sizes and an application-managed list.
Custom button, select and cancel
No documents chosen.
select returns a new File[] list. It replaces the application list in this example. Cancellation preserves the previous selection; clear() clears the native input, so reset the list separately.
Default button: sizes and disabled
Last single selection: none.
accept is a browser hint. The application validates type, size and content. This component does not send files over the network.
No files chosen yet. Documents: 0.
Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlFilePicker, type WlFilePickerExpose, WlIcon } from "legato-ui";
import { ref } from "vue";
const picker = ref<WlFilePickerExpose | null>(null);
const files = ref<File[]>([]);
const singleFiles = ref<File[]>([]);
const message = ref("No files chosen yet.");
function selectFiles(batch: File[]) {
files.value = batch;
message.value = `${"Files selected: "}${batch.length}.`;
}
function cancelSelection() {
message.value = "Selection cancelled. The previous file list is preserved.";
}
function clear() {
picker.value?.clear();
files.value = [];
singleFiles.value = [];
message.value = "The file list and native input are cleared.";
}
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlFilePicker">
<section class="wl-stack" data-space="md">
<h3 class="wl-text-title">{{ "Custom button, select and cancel" }}</h3>
<WlFilePicker
ref="picker"
multiple
accept=".pdf,.txt"
@select="selectFiles"
@cancel="cancelSelection"
>
<template #trigger="{ choose, disabled, attrs }"><WlButton
v-bind="attrs"
variant="primary"
:disabled="disabled"
@click="choose"
><template #icon><WlIcon name="upload" :size="18" /></template>{{ "Choose documents" }}</WlButton></template>
</WlFilePicker>
<ul v-if="files.length" class="wl-stack docs-file-list" data-space="sm">
<li v-for="(file, index) in files" :key="`${file.name}:${index}`">{{
file.name
}} — {{ file.size }} {{ "bytes" }}</li>
</ul>
<p v-else class="wl-text-small">{{ "No documents chosen." }}</p>
<div class="wl-inline" data-space="sm">
<WlButton size="sm" @click="picker?.choose()">{{ "Open through ref" }}</WlButton>
<WlButton size="sm" @click="clear">{{ "Clear files" }}</WlButton>
</div>
<p class="wl-text-small wl-text-muted">{{ "select returns a new File[] list. It replaces the application list in this example. Cancellation preserves the previous selection; clear() clears the native input, so reset the list separately." }}</p>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-title">{{ "Default button: sizes and disabled" }}</h3>
<div class="wl-inline" data-space="md"><WlFilePicker
v-for="size in ['sm', 'md', 'lg'] as const"
:key="size"
:size="size"
accept=".txt"
:choose-label="`${'One TXT, '}${size}`"
@select="singleFiles = $event"
/><WlFilePicker
size="sm"
density="compact"
choose-label="Compact selection"
accept=".txt"
@select="singleFiles = $event"
/><WlFilePicker choose-label="Unavailable selection" disabled /></div>
<p class="wl-text-small">{{ "Last single selection:" }} {{ singleFiles[0]?.name ?? "none" }}.</p>
<p class="wl-text-small wl-text-muted">{{ "accept is a browser hint. The application validates type, size and content. This component does not send files over the network." }}</p>
<p class="wl-text-small" role="status">{{ message }} {{ "Documents:" }} {{ files.length }}.</p>
</section>
</div>
</template>
<style scoped>
.docs-file-list { margin: 0; padding-inline-start: var(--wl-space-lg); overflow-wrap: anywhere; }
</style>