useFileDialog
Opens the native file selection dialog programmatically without rendering a visible <input type="file"> element.
Loading preview...
The useFileDialog hook creates and manages an off-DOM file input so you can trigger the native file picker from any button or action and read the selected FileList reactively.
Installation
Usage
Examples
Selecting and Clearing Files
Call open() from any click handler to launch the native file dialog and reset() to clear the selection.
Overriding Options Per Invocation
Pass per-call options directly to open() to reuse the same hook instance for different file types.
API Reference
UseFileDialogOptions
Configuration options for the file picker.
Property
Specification
multiple?uniondefault:true
Allow selecting multiple files
Full Signature
accept?stringdefault:'*'
Accepted file types or extensions
Full Signature
capture?string
Media capture source (
'user' or 'environment') for mobile devicesFull Signature
directory?uniondefault:false
Allow selecting directories via
webkitdirectoryFull Signature
reset?uniondefault:false
Reset previously selected files when opening the dialog
Full Signature
onChange?function
Callback fired when files are selected
Full Signature
Parameters
(filesFileList | nullonCancel?function
Callback fired when the file dialog is canceled without selection
Full Signature
Parameters
(UseFileDialogReturn
Selected files and control functions returned by the hook.
Property
Specification
filesunion
Currently selected
FileList, or nullFull Signature
openfunction
Opens the native file picker dialog with optional per-call overrides
Full Signature
Parameters
localOptions?Partial<UseFileDialogOptions>resetfunction
Clears the selected
files state and resets the underlying file inputFull Signature