Skip to main content
The File component allows users to upload files or display files for download.

Basic usage

Constructor

str | list[str] | Callable | None
default:"None"
Default file(s) as filepath(s) or URL(s)
Literal['single', 'multiple', 'directory']
default:"'single'"
Upload mode:
  • "single" - One file
  • "multiple" - Multiple files
  • "directory" - All files in directory
list[str] | None
default:"None"
Allowed file types. Examples:
  • ["image"] - Only images
  • [".pdf", ".docx"] - Specific extensions
  • ["video"] - Only videos
Literal['filepath', 'binary']
default:"'filepath'"
Return format:
  • "filepath" - String path to temporary file
  • "binary" - Bytes object
str | None
default:"None"
Label displayed above component
int | str | float | None
default:"None"
Component height (with scrollbar if needed)
bool | None
default:"None"
Whether file upload is enabled

Events

  • change - Triggered when file selection changes
  • select - Triggered when file is selected
  • clear - Triggered when files are cleared
  • upload - Triggered when file upload completes
  • delete - Triggered when file is deleted
  • download - Triggered when file is downloaded

Examples

PDF files only

Multiple files

Binary mode