WlFilePicker

Opens the browser file picker. The application manages the file list, validates limits and sends files to the server. choose()/clear() methods are available through ref.
Components / Inputs v0.8.0

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>