Docs
File Uploader
A component for uploading files with a preview and save functionality
Drag 'n' drop files here, or click to select files
You can upload 4 files (up to 4 MB each)
Installation
pnpm dlx shadcn@latest add https://devkit.kiron.dev/k/file-uploader
Usage
import { FileUploader } from "@/components/ui/file-uploader"
export function Component() {
return (
<div className="w-full">
<FileUploader />
</div>
)
}Examples
File Upload with Dialog
File Upload with React Hook Form
Props
| Name | Type | Default Value | Description |
|---|---|---|---|
value | File[] | [] | The current value of the file uploader. |
onValueChange | (files: File[]) => void | undefined | Callback function that is called when the value changes. |
onUpload | (files: File[]) => Promise<void> | undefined | Callback function that is called when the files are uploaded. |
progresses | Record<string, number> | {} | An object that maps the file name to the upload progress percentage. |
accept | string[] | [] | An array of accepted file types. |
maxSize | number | Infinity | The maximum file size in bytes. |
maxFileCount | number | Infinity | The maximum number of files that can be uploaded. |
multiple | boolean | false | Whether to allow multiple file uploads. |
disabled | boolean | false | Whether the file uploader is disabled. |