Đi tới nội dung tài liệu
Underverse UI Logo
ComponentMedia & Hình ảnh

FileUpload

FileUpload thuộc nhóm Media & Hình ảnh. Xem demo trực tiếp, cách tích hợp và các lưu ý triển khai.

Bắt đầu nhanh

Import FileUpload từ entry công khai. Các ví dụ bên dưới thể hiện những kiểu tương tác và cấu hình được hỗ trợ.

component.tsxtsx
import { FileUpload } from '@underverse-ui/underverse';

Ví dụ tương tác

Dùng thử FileUpload thật, xem mã ví dụ và tra cứu các prop đã được mô tả.

Đang tải ví dụ tương tác…
Tham chiếu

Tham chiếu API

Tra cứu các thuộc tính, kiểu dữ liệu được chấp nhận, giá trị mặc định và lưu ý về hành vi.

Dữ liệu được sinh từ API TypeScript công khai của thư viện. Kiểu dữ liệu, thuộc tính bắt buộc và giá trị mặc định luôn đồng bộ với mã nguồn.

FileUpload

Component
Thuộc tínhMô tảKiểuMặc định
onUploadCallback when a file is uploaded(file: UploadedFile) => void
onRemoveCallback when a file is removed(fileId: string | number) => void
onChangeCallback when files change(files: UploadedFile[]) => void
uploadHandlerCustom upload handler - if provided, handles actual upload(file: File) => Promise<UploadedFile>
maxSizeMaximum file size in MBnumber50
maxFilesMaximum number of filesnumber10
acceptAccepted file types (e.g., ".pdf,.doc" or "image/*,application/pdf")string
multipleAllow multiple filesbooleantrue
disabledDisabled statebooleanfalse
classNameAdditional class namesstring
showFileListShow file listbooleantrue
variantLayout variant"default" | "compact" | "minimal""default"
sizeSize variant"sm" | "md" | "lg""md"
dragDropTextCustom drag/drop textstring
browseTextCustom browse button textstring
supportedFormatsTextCustom supported formats textstring
showTypeIconsShow file type iconsbooleantrue
allowPreviewAllow file preview (for images)booleantrue
initialFilesInitial filesUploadedFile[][]

Hướng dẫn sử dụng

Dùng FileUpload với nội dung thay thế có ý nghĩa, kích thước rõ ràng và chiến lược tải phù hợp. Tối ưu tài nguyên trước khi đưa vào component.

Trợ năng

Khi dùng FileUpload, hãy giữ trạng thái focus dễ nhận biết, cung cấp tên truy cập khi cần và kiểm tra bàn phím cùng trình đọc màn hình trong ngữ cảnh thực tế.