UIComponentsReact
A drop zone and a list of picked files, each with its preview, name, size, error and a remove button.
Built on the headless File Upload.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/file-upload.jsonIt also adds utils, button. The app needs its setup first: Installation.
Usage
Put FileUploadDropzone (an upload icon over your text, or a default one) and FileUploadTrigger inside FileUpload, then a FileUploadList whose function child renders one FileUploadItem per file with FileUploadItemPreview, FileUploadItemName, FileUploadItemSize and FileUploadItemRemove; a second list with rejected shows the files that were not added, with FileUploadItemError. FileUploadClear removes every file. The Dropzone turns primary while files are dragged over it and destructive when they would be rejected. The picker, drag and drop, paste, the checks, the announcements and the form value come from the headless File Upload.
import {
FileUpload,
FileUploadClear,
FileUploadDropzone,
FileUploadItem,
FileUploadItemError,
FileUploadItemName,
FileUploadItemPreview,
FileUploadItemRemove,
FileUploadItemSize,
FileUploadList,
FileUploadTrigger,
} from '@/components/ui/file-upload'Examples
Default
A drop zone for up to five images, the files and the rejected.
Each file is laid out as an Attachment card: the preview as its image, the name as its title, the size or the error as its description, the remove button as its action. This item takes Base UI's component ID as its slug and one name per Base UI part.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on File Upload's API reference.