Skip to content
On this page

useFileDialog

Category
Last Changed
yesterday

Open file dialog with ease.

Demo

Usage

import { useFileDialog } from '@vueuse/core'

const { files, open, reset } = useFileDialog()
import { useFileDialog } from '@vueuse/core'

const { files, open, reset } = useFileDialog()
<template>
  <button type="button" @click="open">Choose file</button>
</template>
<template>
  <button type="button" @click="open">Choose file</button>
</template>

Type Declarations

export interface UseFileDialogOptions extends ConfigurableDocument {
  /**
   * @default true
   */
  multiple?: boolean
  /**
   * @default '*'
   */
  accept?: string
  /**
   * Select the input source for the capture file.
   * @see [HTMLInputElement Capture](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
   */
  capture?: string
}
export interface UseFileDialogReturn {
  files: Ref<FileList | null>
  open: (localOptions?: Partial<UseFileDialogOptions>) => void
  reset: () => void
}
/**
 * Open file dialog with ease.
 *
 * @see https://vueuse.org/useFileDialog
 * @param options
 */
export declare function useFileDialog(
  options?: UseFileDialogOptions
): UseFileDialogReturn
export interface UseFileDialogOptions extends ConfigurableDocument {
  /**
   * @default true
   */
  multiple?: boolean
  /**
   * @default '*'
   */
  accept?: string
  /**
   * Select the input source for the capture file.
   * @see [HTMLInputElement Capture](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
   */
  capture?: string
}
export interface UseFileDialogReturn {
  files: Ref<FileList | null>
  open: (localOptions?: Partial<UseFileDialogOptions>) => void
  reset: () => void
}
/**
 * Open file dialog with ease.
 *
 * @see https://vueuse.org/useFileDialog
 * @param options
 */
export declare function useFileDialog(
  options?: UseFileDialogOptions
): UseFileDialogReturn

Source

SourceDemoDocs

Contributors

ZHAO Jinxiang
Max
Anthony Fu
Robert Soriano

Changelog

v8.9.4 on 7/17/2022
46192 - fix: explict UseFileDialogReturn type (#1927)
v8.9.1 on 7/8/2022
58a45 - fix: SSR compatible, close #1788
v8.9.0 on 7/6/2022
44526 - feat: new function (#1218)
useFileDialog has loaded