WlFilePicker
Selection
Choose files. Connect server upload in your application.
Full example
<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>Size and density
Choose files. Connect server upload in your application.
Full example
<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>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.
Full 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-subheading">{{ "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-subheading">{{ "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>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
accept | string | Not set | Extensions or MIME types for the file picker. The application validates files. |
multiple | boolean | false | Allows multiple file selection. |
disabled | boolean | false | Disables the trigger and choose(). |
chooseLabel | string | Not set | Default button label; falls back to WlConfig.locale.chooseFiles (Choose files in English). |
ariaLabel | string | Not set | Default button accessible name. |
size | WlSizeSm | "md" | Button size. |
density | WlDensity | "default" | Button density. |
pt | WlPt< | Not set | Root, trigger and input attributes. |
Events
| Event | Payload | When emitted |
|---|---|---|
select | [files: File[]] | Unmodified files from the current selection. The component does not merge them with the previous list. |
cancel | [] | Selection cancelled. The application's file list stays unchanged. |
Slots
| Slot | Type / values | Content |
|---|---|---|
trigger | — | Custom button; parameters { choose, clear, disabled, attrs }. attrs connects focus and ARIA attributes. |
Pass-through: pt
Sections WlFilePicker are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-file-picker | The root section in WlConfig.pt.filepicker configuration. |
trigger | button | The trigger section in WlConfig.pt.filepicker configuration. |
input | input | The input section in WlConfig.pt.filepicker configuration. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- The default trigger is a button with chooseLabel/ariaLabel. Keep the provided attrs and disabled in a custom trigger; use a real button.
- Call choose() from a user action so the browser allows the file picker to open. The button supports Enter and Space.
- select emits the new File[] list; cancel does not change the application list. Describe selection results in text and retain file names.
- clear() clears the native input; reset the application list separately. accept suggests file types to the browser; the application performs validation.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| Tab / Shift+Tab | Move between enabled links, actions and form controls. |
| Enter / Space | Activate native actions; links follow with Enter. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesIn your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.