File dropzonePro
Drag-and-drop upload with type, size and count checks and per-file progress.
When to use
- Uploading attachments, imports, avatars and documents.
When not to use
- A single small file in a dense form: a plain file input is enough.
Installation
Usage
Import it from @/components/ui/file-dropzone after installing.
example.tsx
import { FileDropzone } from "@/components/ui/file-dropzone";
export function Attachments() {
return (
<FileDropzone
accept="image/*,.pdf"
maxSize={5 * 1024 * 1024}
upload={(file, onProgress) => uploadWithProgress("/api/upload", file, onProgress)}
/>
);
}API reference
FileDropzone
A drop target and browse button that validates files and lists them with progress.
| Prop | Type | Default | Description |
|---|---|---|---|
| accept | string | – | Like the input accept attribute: "image/*,.pdf". |
| maxSize / maxFiles / multiple | number / number / boolean | 10 MB / 10 / true | Limits. |
| upload | (file, onProgress) => Promise<void> | – | Upload each file and report 0–1. Throw to mark it failed. |
| onFilesChange | (files: File[]) => void | – | Accepted files whenever the list changes. |
| hint | string | – | Replaces the generated limits line. |
formatBytes
Formats a byte count as B, KB or MB.
No props.
Keyboard interactions
| Keys | Action |
|---|---|
| EnterorSpace | Open the file browser |
| Tab | Reach each file's remove button |
Accessibility
- The drop area is a button described by the limits.
- Rejections are announced with role="alert".
- Each upload is a labelled progressbar; remove buttons name the file.
Motion
- The cloud bobs and the area glows while dragging over.
- Files slide in, progress springs, a check pops on success, removed rows slide out.
Responsive behavior
- Up to 448px; long names truncate.
Performance
- Validation happens before any upload starts.
Notes for AI
- Validate on the server too; accept is only a hint to browsers.
This page as Markdown, for assistants and coding agents:
/components/file-dropzone/markdownThe full library index for assistants is at /llms.txt.
Lode222 doc pagesllms.txt